diff options
Diffstat (limited to 'frontends/atari')
28 files changed, 2150 insertions, 1758 deletions
diff --git a/frontends/atari/Makefile b/frontends/atari/Makefile index 7bc441c33..585f0b217 100644 --- a/frontends/atari/Makefile +++ b/frontends/atari/Makefile @@ -47,6 +47,7 @@ CFLAGS += -U__STRICT_ANSI__ -std=c99 -Dsmall -Dnsatari \ -D_BSD_SOURCE \ -D_XOPEN_SOURCE=600 \ -D_POSIX_C_SOURCE=200112L \ + -DNSLOG_LEVEL_0x0010=NSLOG_LEVEL_INFO \ $(shell $(PKG_CONFIG) --cflags openssl ) \ $(shell $(PKG_CONFIG) --cflags libcurl ) @@ -117,8 +118,8 @@ ATARI_FONT_SOURCE_URL := http://ftp.gnome.org/pub/GNOME/sources/ttf-bitstream-ve #ATARI_FONT_SOURCE_URL := http://localhost/$(ATARI_FONT_NAME).tar.gz ATARI_FONT_TMP_DIR := $(DEPROOT)/../ ATARI_FONT_SOURCE_DIR := $(ATARI_FONT_TMP_DIR)$(ATARI_FONT_NAME)/ -ATARI_GENERIC_RESOURCES := de en it ja -ATARI_RESOURCES := $(addprefix \!NetSurf/Resources/,$(ATARI_GENERIC_RESOURCES)) +ATARI_GENERIC_RESOURCES := de en it ja nl +ATARI_RESOURCES := $(addprefix resources/,$(ATARI_GENERIC_RESOURCES)) # ---------------------------------------------------------------------------- # Install target @@ -167,21 +168,21 @@ endif $(Q)cp $(ATARI_RES_DIR)/netsurf.rsc $(ATARI_TARGET_DIR)res/netsurf.rsc $(Q)cp $(ATARI_RES_DIR)/languages $(ATARI_TARGET_DIR)res/languages $(Q)cp $(ATARI_RES_DIR)/icons/toolbar -R $(ATARI_TARGET_DIR)res/icons - $(Q)cp \!NetSurf/Resources/Icons/* -R $(ATARI_TARGET_DIR)res/icons/ - - $(Q)cp \!NetSurf/Resources/netsurf.png,b60 $(ATARI_TARGET_DIR)res/netsurf.png - $(Q)cp \!NetSurf/Resources/AdBlock,f79 $(ATARI_TARGET_DIR)res/adblock.css - $(Q)cp \!NetSurf/Resources/CSS,f79 $(ATARI_TARGET_DIR)res/default.css - $(Q)cp \!NetSurf/Resources/Quirks,f79 $(ATARI_TARGET_DIR)res/quirks.css - $(Q)cp \!NetSurf/Resources/internal.css,f79 $(ATARI_TARGET_DIR)res/internal.css - $(Q)cp \!NetSurf/Resources/SearchEngines $(ATARI_TARGET_DIR)res/search - $(Q)cp \!NetSurf/Resources/ca-bundle $(ATARI_TARGET_DIR)res/cabundle - $(Q)cp \!NetSurf/Resources/ca-bundle $(ATARI_TARGET_DIR)res/cabundle - $(Q)$(SPLIT_MESSAGES) -l en -p atari -f messages resources/FatMessages > $(ATARI_TARGET_DIR)res/messages - $(Q)cp \!NetSurf/Resources/en/welcome.html,faf $(ATARI_TARGET_DIR)res/welcome.html - $(Q)cp \!NetSurf/Resources/en/maps.html,faf $(ATARI_TARGET_DIR)res/maps.html - $(Q)cp \!NetSurf/Resources/en/licence.html,faf $(ATARI_TARGET_DIR)res/licence.html - $(Q)cp \!NetSurf/Resources/en/credits.html,faf $(ATARI_TARGET_DIR)res/credits.html + $(Q)cp resources/icons/* -R $(ATARI_TARGET_DIR)res/icons/ + + $(Q)cp resources/netsurf.png $(ATARI_TARGET_DIR)res/netsurf.png + $(Q)cp resources/adblock.css $(ATARI_TARGET_DIR)res/adblock.css + $(Q)cp resources/default.css $(ATARI_TARGET_DIR)res/default.css + $(Q)cp resources/quirks.css $(ATARI_TARGET_DIR)res/quirks.css + $(Q)cp resources/internal.css $(ATARI_TARGET_DIR)res/internal.css + $(Q)cp resources/SearchEngines $(ATARI_TARGET_DIR)res/search + $(Q)cp resources/ca-bundle $(ATARI_TARGET_DIR)res/cabundle + $(Q)$(RM) $(ATARI_TARGET_DIR)res/messages + $(Q)$(SPLIT_MESSAGES) -l en -p atari -f messages -o $(ATARI_TARGET_DIR)res/messages resources/FatMessages + $(Q)cp resources/en/welcome.html $(ATARI_TARGET_DIR)res/welcome.html + $(Q)cp resources/en/maps.html $(ATARI_TARGET_DIR)res/maps.html + $(Q)cp resources/en/licence.html $(ATARI_TARGET_DIR)res/licence.html + $(Q)cp resources/en/credits.html $(ATARI_TARGET_DIR)res/credits.html # copy "Bitstream Vera" font: $(Q)cp $(ATARI_FONT_SOURCE_DIR)RELEASENOTES.TXT $(ATARI_TARGET_DIR)res/fonts/ diff --git a/frontends/atari/bitmap.c b/frontends/atari/bitmap.c index cbb719586..ae42da837 100644 --- a/frontends/atari/bitmap.c +++ b/frontends/atari/bitmap.c @@ -81,7 +81,9 @@ static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, uns { struct bitmap * bitmap; - LOG("width %d (rowstride: %d, bpp: %d), height %d, state %u", w, rowstride, bpp, h, state); + NSLOG(netsurf, INFO, + "width %d (rowstride: %d, bpp: %d), height %d, state %u", w, + rowstride, bpp, h, state); if( rowstride == 0) { rowstride = bpp * w; @@ -107,10 +109,10 @@ static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, uns } else { free(bitmap); bitmap=NULL; - LOG("Out of memory!"); + NSLOG(netsurf, INFO, "Out of memory!"); } } - LOG("bitmap %p", bitmap); + NSLOG(netsurf, INFO, "bitmap %p", bitmap); return bitmap; } @@ -194,7 +196,7 @@ static unsigned char *bitmap_get_buffer(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return NULL; } @@ -218,7 +220,7 @@ size_t atari_bitmap_get_rowstride(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } return bm->rowstride; @@ -231,7 +233,7 @@ void atari_bitmap_destroy(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return; } @@ -272,11 +274,12 @@ static void bitmap_set_opaque(void *bitmap, bool opaque) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return; } - LOG("setting bitmap %p to %s", bm, opaque ? "opaque" : "transparent"); + NSLOG(netsurf, INFO, "setting bitmap %p to %s", bm, + opaque ? "opaque" : "transparent"); bm->opaque = opaque; } @@ -293,7 +296,7 @@ static bool bitmap_test_opaque(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return false; } @@ -305,11 +308,12 @@ static bool bitmap_test_opaque(void *bitmap) while (tst-- > 0) { if (bm->pixdata[(tst << 2) + 3] != 0xff) { - LOG("bitmap %p has transparency", bm); + NSLOG(netsurf, INFO, + "bitmap %p has transparency", bm); return false; } } - LOG("bitmap %p is opaque", bm); + NSLOG(netsurf, INFO, "bitmap %p is opaque", bm); return true; } @@ -320,7 +324,7 @@ bool atari_bitmap_get_opaque(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return false; } @@ -334,7 +338,7 @@ int atari_bitmap_get_width(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } @@ -348,7 +352,7 @@ int atari_bitmap_get_height(void *bitmap) struct bitmap *bm = bitmap; if (bitmap == NULL) { - LOG("NULL bitmap!"); + NSLOG(netsurf, INFO, "NULL bitmap!"); return 0; } return(bm->height); diff --git a/frontends/atari/certview.c b/frontends/atari/certview.c index 6950d31f8..80d18a059 100644 --- a/frontends/atari/certview.c +++ b/frontends/atari/certview.c @@ -81,7 +81,7 @@ static nserror atari_sslcert_viewer_init_phase2(struct core_window *cw, assert(ssl_d); - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); return(sslcert_viewer_init(cb_t, cw, ssl_d)); } @@ -97,7 +97,7 @@ static void atari_sslcert_viewer_finish(struct core_window *cw) /* This will also free the session data: */ sslcert_viewer_fini(cvwin->ssl_session_data); - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); } static void atari_sslcert_viewer_draw(struct core_window *cw, int x, @@ -123,7 +123,7 @@ static void atari_sslcert_viewer_keypress(struct core_window *cw, uint32_t ucs4) cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw); - LOG("ucs4: %"PRIu32, ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); sslcert_viewer_keypress(cvwin->ssl_session_data, ucs4); } @@ -150,14 +150,14 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) short retval = 0; OBJECT *toolbar; - LOG("win %p", win); + NSLOG(netsurf, INFO, "win %p", win); if(ev_out->emo_events & MU_MESAG){ switch (msg[0]) { case WM_TOOLBAR: toolbar = gemtk_obj_get_tree(TOOLBAR_SSL_CERT); - LOG("CERTVIEWER WM_TOOLBAR"); + NSLOG(netsurf, INFO, "CERTVIEWER WM_TOOLBAR"); tv = (struct core_window*) gemtk_wm_get_user_data(win); assert(tv); cvwin = (struct atari_sslcert_viewer_s *) @@ -238,7 +238,7 @@ static void atari_sslcert_viewer_init(struct atari_sslcert_viewer_s * cvwin, if (cvwin->tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, "Failed to allocate treeview"); return; } @@ -280,7 +280,7 @@ static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin) assert(cvwin->init); assert(cvwin->window); - LOG("cvwin %p", cvwin); + NSLOG(netsurf, INFO, "cvwin %p", cvwin); if (atari_treeview_is_open(cvwin->tv)) atari_treeview_close(cvwin->tv); @@ -289,5 +289,5 @@ static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin) cvwin->window = NULL; atari_treeview_delete(cvwin->tv); free(cvwin); - LOG("done"); + NSLOG(netsurf, INFO, "done"); } diff --git a/frontends/atari/cookies.c b/frontends/atari/cookies.c index 9045009fc..df2de0d4c 100644 --- a/frontends/atari/cookies.c +++ b/frontends/atari/cookies.c @@ -63,7 +63,7 @@ static nserror atari_cookie_manager_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t) { - LOG("cw %p",cw); + NSLOG(netsurf, INFO, "cw %p", cw); return(cookie_manager_init(cb_t, cw)); } @@ -71,7 +71,7 @@ atari_cookie_manager_init_phase2(struct core_window *cw, static void atari_cookie_manager_finish(struct core_window *cw) { - LOG("cw %p",cw); + NSLOG(netsurf, INFO, "cw %p", cw); cookie_manager_fini(); } @@ -89,7 +89,7 @@ atari_cookie_manager_draw(struct core_window *cw, static void atari_cookie_manager_keypress(struct core_window *cw, uint32_t ucs4) { - LOG("ucs4: %"PRIu32, ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); cookie_manager_keypress(ucs4); } @@ -108,13 +108,13 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) { short retval = 0; - LOG("win %p", win); + NSLOG(netsurf, INFO, "win %p", win); if (ev_out->emo_events & MU_MESAG) { switch (msg[0]) { case WM_TOOLBAR: - LOG("WM_TOOLBAR"); + NSLOG(netsurf, INFO, "WM_TOOLBAR"); break; case WM_CLOSED: @@ -158,7 +158,8 @@ void atari_cookie_manager_init(void) if (atari_cookie_manager.tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, + "Failed to allocate treeview"); return; } @@ -209,7 +210,7 @@ void atari_cookie_manager_destroy(void) atari_treeview_delete(atari_cookie_manager.tv); atari_cookie_manager.init = false; } - LOG("done"); + NSLOG(netsurf, INFO, "done"); } diff --git a/frontends/atari/ctxmenu.c b/frontends/atari/ctxmenu.c index e25d8e522..eb6cc1611 100644 --- a/frontends/atari/ctxmenu.c +++ b/frontends/atari/ctxmenu.c @@ -216,7 +216,7 @@ void context_popup(struct gui_window * gw, short x, short y) browser_window_navigate( gw->browser->bw, hlcache_handle_get_url(ctx->ccdata.object), - browser_window_get_url(gw->browser->bw), + browser_window_access_url(gw->browser->bw), BW_NAVIGATE_DOWNLOAD, NULL, NULL, @@ -232,7 +232,7 @@ void context_popup(struct gui_window * gw, short x, short y) error = browser_window_navigate( gw->browser->bw, ctx->ccdata.link, - browser_window_get_url(gw->browser->bw), + browser_window_access_url(gw->browser->bw), BW_NAVIGATE_DOWNLOAD, NULL, NULL, @@ -269,7 +269,7 @@ void context_popup(struct gui_window * gw, short x, short y) error = browser_window_create( BW_CREATE_HISTORY | BW_CREATE_CLONE, ctx->ccdata.link, - browser_window_get_url(gw->browser->bw), + browser_window_access_url(gw->browser->bw), gw->browser->bw, NULL); if (error != NSERROR_OK) { @@ -288,7 +288,9 @@ void context_popup(struct gui_window * gw, short x, short y) /* the GEMDOS cmdline contains the length of the commandline in the first byte: */ cmdline[0] = (unsigned char)strlen(tempfile); - LOG("Creating temporay source file: %s\n", tempfile); + NSLOG(netsurf, INFO, + "Creating temporay source file: %s\n", + tempfile); fp_tmpfile = fopen(tempfile, "w"); if (fp_tmpfile != NULL){ fwrite(data, size, 1, fp_tmpfile); @@ -306,7 +308,8 @@ void context_popup(struct gui_window * gw, short x, short y) } } else { - LOG("Invalid content!"); + NSLOG(netsurf, INFO, + "Invalid content!"); } } else { form_alert(0, "[1][Set option \"atari_editor\".][OK]"); diff --git a/frontends/atari/deskmenu.c b/frontends/atari/deskmenu.c index addba2764..34d7be0b8 100644 --- a/frontends/atari/deskmenu.c +++ b/frontends/atari/deskmenu.c @@ -181,7 +181,7 @@ static void __CDECL menu_about(short item, short title, void *data) nserror error; char buf[PATH_MAX]; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "abort menu"); strcpy((char*)&buf, "file://"); strncat((char*)&buf, (char*)"./doc/README.TXT", PATH_MAX - (strlen("file://")+1) ); @@ -208,7 +208,7 @@ static void __CDECL menu_new_win(short item, short title, void *data) nserror error; const char *addr; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (nsoption_charp(homepage_url) != NULL) { addr = nsoption_charp(homepage_url); @@ -236,7 +236,7 @@ static void __CDECL menu_open_url(short item, short title, void *data) { struct gui_window * gw; struct browser_window * bw ; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); gw = input_window; if( gw == NULL ) { @@ -251,7 +251,7 @@ static void __CDECL menu_open_url(short item, short title, void *data) static void __CDECL menu_open_file(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); const char * filename = file_select(messages_get("OpenFile"), ""); if( filename != NULL ){ @@ -280,7 +280,7 @@ static void __CDECL menu_open_file(short item, short title, void *data) static void __CDECL menu_close_win(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; gui_window_destroy( input_window ); @@ -288,7 +288,7 @@ static void __CDECL menu_close_win(short item, short title, void *data) static void __CDECL menu_save_page(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); static bool init = true; bool is_folder=false; const char * path; @@ -319,7 +319,7 @@ static void __CDECL menu_quit(short item, short title, void *data) { short buff[8]; memset( &buff, 0, sizeof(short)*8 ); - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); gemtk_wm_send_msg(NULL, AP_TERM, 0, 0, 0, 0); } @@ -331,21 +331,21 @@ static void __CDECL menu_cut(short item, short title, void *data) static void __CDECL menu_copy(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window != NULL ) browser_window_key_press( input_window->browser->bw, NS_KEY_COPY_SELECTION); } static void __CDECL menu_paste(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window != NULL ) browser_window_key_press( input_window->browser->bw, NS_KEY_PASTE); } static void __CDECL menu_find(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (input_window != NULL) { if (input_window->search) { window_close_search(input_window->root); @@ -358,13 +358,13 @@ static void __CDECL menu_find(short item, short title, void *data) static void __CDECL menu_choices(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); open_settings(); } static void __CDECL menu_stop(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; @@ -378,7 +378,7 @@ static void __CDECL menu_reload(short item, short title, void *data) if(input_window == NULL) return; toolbar_reload_click(input_window->root->toolbar); - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); } @@ -408,7 +408,7 @@ static void __CDECL menu_dec_scale(short item, short title, void *data) static void __CDECL menu_toolbars(short item, short title, void *data) { static int state = 0; - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window != null && input_window->root->toolbar != null ){ state = !state; // TODO: implement toolbar hide @@ -418,7 +418,7 @@ static void __CDECL menu_toolbars(short item, short title, void *data) static void __CDECL menu_savewin(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (input_window && input_window->browser) { GRECT rect; wind_get_grect(gemtk_wm_get_handle(input_window->root->win), WF_CURRXYWH, @@ -438,7 +438,7 @@ static void __CDECL menu_savewin(short item, short title, void *data) static void __CDECL menu_debug_render(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); html_redraw_debug = !html_redraw_debug; if( input_window != NULL ) { if ( input_window->browser != NULL @@ -469,7 +469,7 @@ static void __CDECL menu_bg_images(short item, short title, void *data) static void __CDECL menu_back(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; toolbar_back_click(input_window->root->toolbar); @@ -477,7 +477,7 @@ static void __CDECL menu_back(short item, short title, void *data) static void __CDECL menu_forward(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; toolbar_forward_click(input_window->root->toolbar); @@ -485,7 +485,7 @@ static void __CDECL menu_forward(short item, short title, void *data) static void __CDECL menu_home(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; toolbar_home_click(input_window->root->toolbar); @@ -493,24 +493,24 @@ static void __CDECL menu_home(short item, short title, void *data) static void __CDECL menu_lhistory(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if( input_window == NULL ) return; } static void __CDECL menu_ghistory(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); atari_global_history_open(); } static void __CDECL menu_add_bookmark(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); if (input_window) { if( browser_window_has_content(input_window->browser->bw) ){ atari_hotlist_add_page( - nsurl_access(browser_window_get_url(input_window->browser->bw)), + nsurl_access(browser_window_access_url(input_window->browser->bw)), NULL ); } @@ -519,26 +519,26 @@ static void __CDECL menu_add_bookmark(short item, short title, void *data) static void __CDECL menu_bookmarks(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); atari_hotlist_open(); } static void __CDECL menu_cookies(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); atari_cookie_manager_open(); } static void __CDECL menu_vlog(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); verbose_log = !verbose_log; menu_icheck(h_gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0); } static void __CDECL menu_help_content(short item, short title, void *data) { - LOG("%s", __FUNCTION__); + NSLOG(netsurf, INFO, "%s", __FUNCTION__); } /* @@ -580,14 +580,16 @@ static void register_menu_str( struct s_menu_item_evnt * mi ) while (i > 2) { if ((strncmp(" ", &str[i], 2) == 0) && (strlen(&str[i]) > 2)) { // "Standard" Keyboard Shortcut Element found: - LOG("Standard Keyboard Shortcut: \"%s\"\n", &str[i]); + NSLOG(netsurf, INFO, + "Standard Keyboard Shortcut: \"%s\"\n", &str[i]); x = i+2; is_std_shortcut = true; break; } if( str[i] == '['){ - LOG("Keyboard Shortcut: \"%s\"\n", &str[i]); + NSLOG(netsurf, INFO, "Keyboard Shortcut: \"%s\"\n", + &str[i]); // "Custom" Keyboard Shortcut Element found (identified by [): x = i; break; @@ -662,8 +664,12 @@ static void register_menu_str( struct s_menu_item_evnt * mi ) } } - LOG("Registered keyboard shortcut for \"%s\" => mod: %d, ""keycode: %ld, ascii: %c\n", - str, accel->mod, accel->keycode, accel->ascii); + NSLOG(netsurf, INFO, + "Registered keyboard shortcut for \"%s\" => mod: %d, ""keycode: %ld, ascii: %c\n", + str, + accel->mod, + accel->keycode, + accel->ascii); } } diff --git a/frontends/atari/download.c b/frontends/atari/download.c index d756e6694..7a1c7d2b7 100644 --- a/frontends/atari/download.c +++ b/frontends/atari/download.c @@ -194,7 +194,7 @@ static void on_close(struct gui_download_window * dw) static void gui_download_window_destroy( struct gui_download_window * gdw) { - LOG("gdw %p", gdw); + NSLOG(netsurf, INFO, "gdw %p", gdw); if (gdw->status == NSATARI_DOWNLOAD_WORKING) { download_context_abort(gdw->ctx); @@ -253,7 +253,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent) char alert[200]; - LOG("Creating download window for gui window: %p", parent); + NSLOG(netsurf, INFO, "Creating download window for gui window: %p", + parent); /* TODO: Implement real form and use messages file strings! */ @@ -330,7 +331,8 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent) gemtk_wm_set_toolbar_redraw_func(gdw->guiwin, toolbar_redraw_cb); strncpy((char*)&gdw->lbl_file, filename, MAX_SLEN_LBL_FILE-1); - LOG("created download: %s (total size: %d)", gdw->destination, gdw->size_total); + NSLOG(netsurf, INFO, "created download: %s (total size: %d)", + gdw->destination, gdw->size_total); GRECT work, curr; work.g_x = 0; @@ -357,7 +359,7 @@ static nserror gui_download_window_data(struct gui_download_window *dw, uint32_t tnow = clck / (CLOCKS_PER_SEC>>3); uint32_t sdiff = (clck / (CLOCKS_PER_SEC)) - dw->start; - LOG("dw %p",dw); + NSLOG(netsurf, INFO, "dw %p", dw); if (dw->abort == true){ dw->status = NSATARI_DOWNLOAD_CANCELED; @@ -405,7 +407,7 @@ static nserror gui_download_window_data(struct gui_download_window *dw, static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg) { - LOG("%s", error_msg); + NSLOG(netsurf, INFO, "%s", error_msg); strncpy((char*)&dw->lbl_file, error_msg, MAX_SLEN_LBL_FILE-1); dw->status = NSATARI_DOWNLOAD_ERROR; @@ -416,7 +418,7 @@ static void gui_download_window_error(struct gui_download_window *dw, static void gui_download_window_done(struct gui_download_window *dw) { - LOG("dw %p", dw); + NSLOG(netsurf, INFO, "dw %p", dw); // TODO: change abort to close dw->status = NSATARI_DOWNLOAD_COMPLETE; diff --git a/frontends/atari/filetype.c b/frontends/atari/filetype.c index d27076e9c..706347137 100644 --- a/frontends/atari/filetype.c +++ b/frontends/atari/filetype.c @@ -36,7 +36,7 @@ const char *fetch_filetype(const char *unix_path) char * res = (char*)"text/html"; l = strlen(unix_path); - LOG("unix path: %s", unix_path); + NSLOG(netsurf, INFO, "unix path: %s", unix_path); /* This line is added for devlopment versions running from the root dir: */ if( strchr( unix_path, (int)'.' ) ){ @@ -85,6 +85,6 @@ const char *fetch_filetype(const char *unix_path) } } - LOG("mime type: %s", res); + NSLOG(netsurf, INFO, "mime type: %s", res); return( res ); } diff --git a/frontends/atari/findfile.c b/frontends/atari/findfile.c index 45ca6d916..8784727bc 100644 --- a/frontends/atari/findfile.c +++ b/frontends/atari/findfile.c @@ -31,7 +31,7 @@ char * local_file_to_url( const char * filename ) #define BACKSLASH 0x5C char * url; - LOG("in: %s", filename); + NSLOG(netsurf, INFO, "in: %s", filename); if( strlen(filename) <= 2){ return( NULL ); @@ -55,7 +55,7 @@ char * local_file_to_url( const char * filename ) free(fname_local); - LOG("out: %s", url); + NSLOG(netsurf, INFO, "out: %s", url); return( url ); #undef BACKSLASH @@ -81,10 +81,10 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) { char *cdir = NULL; char t[PATH_MAX]; - LOG("%s (def: %s)", filename, def); + NSLOG(netsurf, INFO, "%s (def: %s)", filename, def); strcpy(t, NETSURF_GEM_RESPATH); strcat(t, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) != NULL) { if (access(buf, R_OK) == 0) { return buf; @@ -92,7 +92,7 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) } strcpy(t, "./"); strcat(t, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) != NULL) { if (access(buf, R_OK) == 0) { return buf; @@ -104,7 +104,7 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) strcpy(t, cdir); strcat(t, "/.netsurf/"); strcat(t, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) != NULL) { if (access(buf, R_OK) == 0) return buf; @@ -116,19 +116,19 @@ char * atari_find_resource(char *buf, const char *filename, const char *def) if (gemdos_realpath(cdir, buf) != NULL) { strcat(buf, "/"); strcat(buf, filename); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (access(buf, R_OK) == 0) return buf; } } if (def[0] == '~') { snprintf(t, PATH_MAX, "%s%s", getenv("HOME"), def + 1); - LOG("checking %s", (char *)&t); + NSLOG(netsurf, INFO, "checking %s", (char *)&t); if (gemdos_realpath(t, buf) == NULL) { strcpy(buf, t); } } else { - LOG("checking %s", (char *)def); + NSLOG(netsurf, INFO, "checking %s", (char *)def); if (gemdos_realpath(def, buf) == NULL) { strcpy(buf, def); } diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c index d4a6915cd..6ee63b301 100644 --- a/frontends/atari/gui.c +++ b/frontends/atari/gui.c @@ -39,6 +39,7 @@ #include "netsurf/content.h" #include "netsurf/cookie_db.h" #include "netsurf/url_db.h" +#include "netsurf/plotters.h" #include "content/backing_store.h" #include "atari/gemtk/gemtk.h" @@ -138,11 +139,11 @@ static void atari_poll(void) evnt_multi_fast(&aes_event_in, aes_msg_out, &aes_event_out); if(gemtk_wm_dispatch_event(&aes_event_in, &aes_event_out, aes_msg_out) == 0) { if( (aes_event_out.emo_events & MU_MESAG) != 0 ) { - LOG("WM: %d\n", aes_msg_out[0]); + NSLOG(netsurf, INFO, "WM: %d\n", aes_msg_out[0]); switch(aes_msg_out[0]) { case MN_SELECTED: - LOG("Menu Item: %d\n", aes_msg_out[4]); + NSLOG(netsurf, INFO, "Menu Item: %d\n", aes_msg_out[4]); deskmenu_dispatch_item(aes_msg_out[3], aes_msg_out[4]); break; @@ -194,13 +195,14 @@ gui_window_create(struct browser_window *bw, gui_window_create_flags flags) { struct gui_window *gw=NULL; - LOG("gw: %p, BW: %p, existing %p, flags: %d\n", gw, bw, existing, (int)flags); + NSLOG(netsurf, INFO, "gw: %p, BW: %p, existing %p, flags: %d\n", gw, bw, + existing, (int)flags); gw = calloc(1, sizeof(struct gui_window)); if (gw == NULL) return NULL; - LOG("new window: %p, bw: %p\n", gw, bw); + NSLOG(netsurf, INFO, "new window: %p, bw: %p\n", gw, bw); window_create(gw, bw, existing, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\ |WIDGET_SCROLL); if (gw->root->win) { @@ -252,7 +254,7 @@ void gui_window_destroy(struct gui_window *gw) if (gw == NULL) return; - LOG("%s\n", __FUNCTION__); + NSLOG(netsurf, INFO, "%s\n", __FUNCTION__); if (input_window == gw) { gui_set_input_gui_window(NULL); @@ -292,25 +294,27 @@ void gui_window_destroy(struct gui_window *gw) } /** - * Find the current dimensions of a browser window's content area. + * Find the current dimensions of a atari browser window content area. * - * \param w gui_window to measure - * \param width receives width of window + * \param gw The gui window to measure content area of. + * \param width receives width of window * \param height receives height of window * \param scaled whether to return scaled values + * \return NSERROR_OK on sucess and width and height updated + * else error code. */ -static void -gui_window_get_dimensions(struct gui_window *w, +static nserror +gui_window_get_dimensions(struct gui_window *gw, int *width, int *height, bool scaled) { - if (w == NULL) - return; GRECT rect; - window_get_grect(w->root, BROWSER_AREA_CONTENT, &rect); + window_get_grect(gw->root, BROWSER_AREA_CONTENT, &rect); *width = rect.g_w; *height = rect.g_h; + + return NSERROR_OK; } /** @@ -374,44 +378,41 @@ void atari_window_set_status(struct gui_window *w, const char *text) window_set_stauts(w->root, (char*)text); } -static void atari_window_reformat(struct gui_window *gw) + +/** + * Invalidates an area of an atari browser window + * + * \param gw gui_window + * \param rect area to redraw or NULL for the entire window area + * \return NSERROR_OK on success or appropriate error code + */ +static nserror +atari_window_invalidate_area(struct gui_window *gw, + const struct rect *rect) { - int width = 0, height = 0; + GRECT area; - if (gw != NULL) { - gui_window_get_dimensions(gw, &width, &height, true); - browser_window_reformat(gw->browser->bw, false, width, height); + if (gw == NULL) { + return NSERROR_BAD_PARAMETER; } -} -static void gui_window_redraw_window(struct gui_window *gw) -{ - //CMP_BROWSER b; - GRECT rect; - if (gw == NULL) - return; - //b = gw->browser; - window_get_grect(gw->root, BROWSER_AREA_CONTENT, &rect); - window_schedule_redraw_grect(gw->root, &rect); -} + window_get_grect(gw->root, BROWSER_AREA_CONTENT, &area); -static void gui_window_update_box(struct gui_window *gw, const struct rect *rect) -{ - GRECT area; - struct gemtk_wm_scroll_info_s *slid; + if (rect != NULL) { + struct gemtk_wm_scroll_info_s *slid; - if (gw == NULL) - return; + slid = gemtk_wm_get_scroll_info(gw->root->win); - slid = gemtk_wm_get_scroll_info(gw->root->win); + area.g_x += rect->x0 - (slid->x_pos * slid->x_unit_px); + area.g_y += rect->y0 - (slid->y_pos * slid->y_unit_px); + area.g_w = rect->x1 - rect->x0; + area.g_h = rect->y1 - rect->y0; + } - window_get_grect(gw->root, BROWSER_AREA_CONTENT, &area); - area.g_x += rect->x0 - (slid->x_pos * slid->x_unit_px); - area.g_y += rect->y0 - (slid->y_pos * slid->y_unit_px); - area.g_w = rect->x1 - rect->x0; - area.g_h = rect->y1 - rect->y0; //dbg_grect("update box", &area); window_schedule_redraw_grect(gw->root, &area); + + return NSERROR_OK; } bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy) @@ -424,17 +425,31 @@ bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy) return( true ); } -static void gui_window_set_scroll(struct gui_window *w, int sx, int sy) +/** + * Set the scroll position of a atari browser window. + * + * Scrolls the viewport to ensure the specified rectangle of the + * content is shown. The atari implementation scrolls the contents so + * the specified point in the content is at the top of the viewport. + * + * \param gw gui window to scroll + * \param rect The rectangle to ensure is shown. + * \return NSERROR_OK on success or apropriate error code. + */ +static nserror +gui_window_set_scroll(struct gui_window *gw, const struct rect *rect) { - if ( (w == NULL) - || (w->browser->bw == NULL) - || (!browser_window_has_content(w->browser->bw))) - return; + if ((gw == NULL) || + (gw->browser->bw == NULL) || + (!browser_window_has_content(gw->browser->bw))) { + return NSERROR_BAD_PARAMETER; + } - LOG("scroll (gui_window: %p) %d, %d\n", w, sx, sy); - window_scroll_by(w->root, sx, sy); - return; + NSLOG(netsurf, INFO, "scroll (gui_window: %p) %d, %d\n", gw, rect->x0, + rect->y0); + window_scroll_by(gw->root, rect->x0, rect->y0); + return NSERROR_OK; } /** @@ -679,7 +694,7 @@ static void gui_window_new_content(struct gui_window *w) slid->x_pos = 0; slid->y_pos = 0; gemtk_wm_update_slider(w->root->win, GEMTK_WM_VH_SLIDER); - gui_window_redraw_window(w); + atari_window_invalidate_area(w, NULL); } @@ -758,7 +773,8 @@ static void gui_401login_open(nsurl *url, const char *realm, char * out = NULL; bres = login_form_do( url, (char*)realm, &out); if (bres) { - LOG("url: %s, realm: %s, auth: %s\n", nsurl_access(url), realm, out); + NSLOG(netsurf, INFO, "url: %s, realm: %s, auth: %s\n", + nsurl_access(url), realm, out); urldb_set_auth_details(url, realm, out); } if (out != NULL) { @@ -776,7 +792,7 @@ gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, void *cbpw) { struct sslcert_session_data *data; - LOG("url %s", nsurl_access(url)); + NSLOG(netsurf, INFO, "url %s", nsurl_access(url)); // TODO: localize string int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort|Details...]"); @@ -799,7 +815,8 @@ gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs, void gui_set_input_gui_window(struct gui_window *gw) { - LOG("Setting input window from: %p to %p\n", input_window, gw); + NSLOG(netsurf, INFO, "Setting input window from: %p to %p\n", + input_window, gw); input_window = gw; } @@ -810,7 +827,7 @@ struct gui_window * gui_get_input_window(void) static void gui_quit(void) { - LOG("quitting"); + NSLOG(netsurf, INFO, "quitting"); struct gui_window *gw = window_list; struct gui_window *tmp = window_list; @@ -839,9 +856,9 @@ static void gui_quit(void) rsrc_free(); - LOG("Shutting down plotter"); + NSLOG(netsurf, INFO, "Shutting down plotter"); plot_finalise(); - LOG("done"); + NSLOG(netsurf, INFO, "done"); } /** @@ -853,7 +870,7 @@ process_cmdline(int argc, char** argv) int opt; bool set_default_dimensions = true; - LOG("argc %d, argv %p", argc, argv); + NSLOG(netsurf, INFO, "argc %d, argv %p", argc, argv); if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) { @@ -946,7 +963,7 @@ static nserror set_defaults(struct nsoption_s *defaults) /* Set defaults for absent option strings */ nsoption_setnull_charp(cookie_file, strdup("cookies")); if (nsoption_charp(cookie_file) == NULL) { - LOG("Failed initialising string options"); + NSLOG(netsurf, INFO, "Failed initialising string options"); return NSERROR_BAD_PARAMETER; } return NSERROR_OK; @@ -963,7 +980,7 @@ static void gui_init(int argc, char** argv) OBJECT * cursors; atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc"); - LOG("Using RSC file: %s ", (char *)&buf); + NSLOG(netsurf, INFO, "Using RSC file: %s ", (char *)&buf); if (rsrc_load(buf)==0) { char msg[1024]; @@ -999,15 +1016,16 @@ static void gui_init(int argc, char** argv) create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_HELP, cursors, &gem_cursors.help); - LOG("Enabling core select menu"); + NSLOG(netsurf, INFO, "Enabling core select menu"); nsoption_set_bool(core_select_menu, true); - LOG("Loading url.db from: %s", nsoption_charp(url_file)); + NSLOG(netsurf, INFO, "Loading url.db from: %s", nsoption_charp(url_file)); if( strlen(nsoption_charp(url_file)) ) { urldb_load(nsoption_charp(url_file)); } - LOG("Loading cookies from: %s", nsoption_charp(cookie_file)); + NSLOG(netsurf, INFO, "Loading cookies from: %s", + nsoption_charp(cookie_file)); if( strlen(nsoption_charp(cookie_file)) ) { urldb_load_cookies(nsoption_charp(cookie_file)); } @@ -1015,11 +1033,16 @@ static void gui_init(int argc, char** argv) if (process_cmdline(argc,argv) != true) die("unable to process command line.\n"); - LOG("Initializing NKC..."); + NSLOG(netsurf, INFO, "Initializing NKC..."); nkc_init(); - LOG("Initializing plotters..."); - plot_init(nsoption_charp(atari_font_driver)); + NSLOG(netsurf, INFO, "Initializing plotters..."); + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &atari_plotters + }; + plot_init(&ctx, nsoption_charp(atari_font_driver)); aes_event_in.emi_m1leave = MO_LEAVE; aes_event_in.emi_m1.g_w = 1; @@ -1045,13 +1068,11 @@ static void gui_init(int argc, char** argv) static struct gui_window_table atari_window_table = { .create = gui_window_create, .destroy = gui_window_destroy, - .redraw = gui_window_redraw_window, - .update = gui_window_update_box, + .invalidate = atari_window_invalidate_area, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, .update_extent = gui_window_update_extent, - .reformat = atari_window_reformat, .set_title = gui_window_set_title, .set_url = gui_window_set_url, @@ -1156,18 +1177,18 @@ int main(int argc, char** argv) ret = messages_add_from_file(messages); /* common initialisation */ - LOG("Initialising core..."); + NSLOG(netsurf, INFO, "Initialising core..."); ret = netsurf_init(store); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); } - LOG("Initializing GUI..."); + NSLOG(netsurf, INFO, "Initializing GUI..."); gui_init(argc, argv); graf_mouse( ARROW , NULL); - LOG("Creating initial browser window..."); + NSLOG(netsurf, INFO, "Creating initial browser window..."); addr = option_homepage_url; if (strncmp(addr, "file://", 7) && strncmp(addr, "http://", 7)) { if (stat(addr, &stat_buf) == 0) { @@ -1189,7 +1210,7 @@ int main(int argc, char** argv) if (ret != NSERROR_OK) { atari_warn_user(messages_get_errorcode(ret), 0); } else { - LOG("Entering Atari event mainloop..."); + NSLOG(netsurf, INFO, "Entering Atari event mainloop..."); while (!atari_quit) { atari_poll(); } @@ -1203,7 +1224,11 @@ int main(int argc, char** argv) fclose(stdout); fclose(stderr); #endif - LOG("exit_gem"); + NSLOG(netsurf, INFO, "exit_gem"); + + /* finalise logging */ + nslog_finalise(); + exit_gem(); return 0; diff --git a/frontends/atari/history.c b/frontends/atari/history.c index 56aafd056..ec602684f 100644 --- a/frontends/atari/history.c +++ b/frontends/atari/history.c @@ -39,13 +39,13 @@ static nserror atari_global_history_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t) { - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); return(global_history_init(cb_t, cw)); } static void atari_global_history_finish(struct core_window *cw) { - LOG("cw %p", cw); + NSLOG(netsurf, INFO, "cw %p", cw); global_history_fini(); } @@ -58,7 +58,7 @@ static void atari_global_history_draw(struct core_window *cw, int x, static void atari_global_history_keypress(struct core_window *cw, uint32_t ucs4) { - LOG("ucs4: %"PRIu32, ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); global_history_keypress(ucs4); } @@ -67,7 +67,7 @@ atari_global_history_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y) { - LOG("x: %d, y: %d\n", x, y); + NSLOG(netsurf, INFO, "x: %d, y: %d\n", x, y); global_history_mouse_action(mouse, x, y); } @@ -82,7 +82,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) { short retval = 0; - LOG("win %p", win); + NSLOG(netsurf, INFO, "win %p", win); if (ev_out->emo_events & MU_MESAG) { switch (msg[0]) { @@ -134,7 +134,8 @@ void atari_global_history_init(void) if (atari_global_history.tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, + "Failed to allocate treeview"); return; } } @@ -181,7 +182,7 @@ void atari_global_history_destroy(void) atari_treeview_delete(atari_global_history.tv); atari_global_history.init = false; } - LOG("done"); + NSLOG(netsurf, INFO, "done"); } void atari_global_history_redraw(void) diff --git a/frontends/atari/hotlist.c b/frontends/atari/hotlist.c index da599161b..3a54c98eb 100644 --- a/frontends/atari/hotlist.c +++ b/frontends/atari/hotlist.c @@ -72,14 +72,14 @@ static struct atari_treeview_callbacks atari_hotlist_treeview_callbacks = { static nserror atari_hotlist_init_phase2(struct core_window *cw, struct core_window_callback_table *cb_t) { - LOG("cw:%p", cw); + NSLOG(netsurf, INFO, "cw:%p", cw); return hotlist_manager_init(cb_t, cw); } static void atari_hotlist_finish(struct core_window *cw) { - LOG("cw:%p", cw); - hotlist_fini(hl.path); + NSLOG(netsurf, INFO, "cw:%p", cw); + hotlist_fini(); } static void atari_hotlist_draw(struct core_window *cw, int x, @@ -93,7 +93,7 @@ static void atari_hotlist_keypress(struct core_window *cw, uint32_t ucs4) { //GUIWIN *gemtk_win; //GRECT area; - LOG("ucs4: %"PRIu32 , ucs4); + NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4); hotlist_keypress(ucs4); //gemtk_win = atari_treeview_get_gemtk_window(cw); //atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &area); @@ -104,7 +104,7 @@ static void atari_hotlist_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y) { - LOG("x: %d, y: %d\n", x, y); + NSLOG(netsurf, INFO, "x: %d, y: %d\n", x, y); hotlist_mouse_action(mouse, x, y); } @@ -123,7 +123,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) GRECT tb_area; GUIWIN * gemtk_win; - LOG("gw:%p", win); + NSLOG(netsurf, INFO, "gw:%p", win); tv = (struct atari_treeview_window*) gemtk_wm_get_user_data(win); cw = (struct core_window *)tv; @@ -132,7 +132,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) switch (msg[0]) { case WM_TOOLBAR: - LOG("WM_TOOLBAR"); + NSLOG(netsurf, INFO, "WM_TOOLBAR"); toolbar = gemtk_obj_get_tree(TOOLBAR_HOTLIST); @@ -198,8 +198,8 @@ void atari_hotlist_init(void) strncpy( (char*)&hl.path, nsoption_charp(hotlist_file), PATH_MAX-1 ); } - LOG("Hotlist: %s", (char *)&hl.path); - hotlist_init(hl.path); + NSLOG(netsurf, INFO, "Hotlist: %s", (char *)&hl.path); + hotlist_init(hl.path, hl.path); if( hl.window == NULL ){ int flags = ATARI_TREEVIEW_WIDGETS; @@ -224,7 +224,8 @@ void atari_hotlist_init(void) if (hl.tv == NULL) { /* handle it properly, clean up previous allocs */ - LOG("Failed to allocate treeview"); + NSLOG(netsurf, INFO, + "Failed to allocate treeview"); return; } @@ -276,7 +277,7 @@ void atari_hotlist_destroy(void) atari_treeview_delete(hl.tv); hl.init = false; } - LOG("done"); + NSLOG(netsurf, INFO, "done"); } void atari_hotlist_redraw(void) @@ -299,7 +300,7 @@ void atari_hotlist_add_page( const char * url, const char * title ) return; if (hotlist_has_url(nsurl)) { - LOG("URL already added as Bookmark"); + NSLOG(netsurf, INFO, "URL already added as Bookmark"); nsurl_unref(nsurl); return; } diff --git a/frontends/atari/misc.h b/frontends/atari/misc.h index e581c23b2..05fd1aeef 100644 --- a/frontends/atari/misc.h +++ b/frontends/atari/misc.h @@ -31,10 +31,12 @@ lbuf[7] = (long)sbuf[7]; #define RECT_TO_GRECT(r,g) \ - (g)->g_x = (r->x0 < r->x1) ? r->x0 : r->x1 ; \ - (g)->g_y = (r->y0 < r->y1) ? r->y0 : r->y1 ; \ - (g)->g_w = (r->x0 < r->x1) ? r->x1 - r->x0 : r->x0 - r->x1 ; \ - (g)->g_h = (r->y0 < r->y1) ? r->y1 - r->y0 : r->y0 - r->y1 ; + do { \ + (g)->g_x = (r->x0 < r->x1) ? r->x0 : r->x1 ; \ + (g)->g_y = (r->y0 < r->y1) ? r->y0 : r->y1 ; \ + (g)->g_w = (r->x0 < r->x1) ? r->x1 - r->x0 : r->x0 - r->x1 ; \ + (g)->g_h = (r->y0 < r->y1) ? r->y1 - r->y0 : r->y0 - r->y1 ; \ + } while(0) diff --git a/frontends/atari/osspec.c b/frontends/atari/osspec.c index f64402e8d..ca042f164 100644 --- a/frontends/atari/osspec.c +++ b/frontends/atari/osspec.c @@ -119,14 +119,14 @@ char *gemdos_realpath(const char * path, char * rpath) return(rpath); } - LOG("realpath in: %s\n", path); + NSLOG(netsurf, INFO, "realpath in: %s\n", path); r = realpath(path, work); if (r != NULL) { unx2dos((const char *)r, rpath); - LOG("realpath out: %s\n", rpath); + NSLOG(netsurf, INFO, "realpath out: %s\n", rpath); return(rpath); } else { - LOG("realpath out: NULL!\n"); + NSLOG(netsurf, INFO, "realpath out: NULL!\n"); } return (NULL); } diff --git a/frontends/atari/plot/font_freetype.c b/frontends/atari/plot/font_freetype.c index 17d3c3bfd..f8109f6f2 100644 --- a/frontends/atari/plot/font_freetype.c +++ b/frontends/atari/plot/font_freetype.c @@ -154,11 +154,12 @@ static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Po error = FT_New_Face(library, ft_face->fontfile, ft_face->index, face); if (error) { - LOG("Could not find font (code %d)\n", error); + NSLOG(netsurf, INFO, "Could not find font (code %d)\n", error); } else { error = FT_Select_Charmap(*face, FT_ENCODING_UNICODE); if (error) { - LOG("Could not select charmap (code %d)\n", error); + NSLOG(netsurf, INFO, + "Could not select charmap (code %d)\n", error); } else { for (cidx = 0; cidx < (*face)->num_charmaps; cidx++) { if ((*face)->charmap == (*face)->charmaps[cidx]) { @@ -168,7 +169,7 @@ static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Po } } } - LOG("Loaded face from %s\n", ft_face->fontfile); + NSLOG(netsurf, INFO, "Loaded face from %s\n", ft_face->fontfile); return error; } @@ -190,7 +191,9 @@ ft_new_face(const char *option, const char *resname, const char *fontfile) } error = FTC_Manager_LookupFace(ft_cmanager, (FTC_FaceID)newf, &aface); if (error) { - LOG("Could not find font face %s (code %d)\n", fontfile, error); + NSLOG(netsurf, INFO, + "Could not find font face %s (code %d)\n", fontfile, + error); free(newf); newf = font_faces[FONT_FACE_DEFAULT]; /* use default */ } @@ -247,7 +250,7 @@ static void ft_fill_scalar(const plot_font_style_t *fstyle, FTC_Scaler srec) srec->face_id = (FTC_FaceID)font_faces[selected_face]; - srec->width = srec->height = (fstyle->size * 64) / FONT_SIZE_SCALE; + srec->width = srec->height = (fstyle->size * 64) / PLOT_STYLE_SCALE; srec->pixel = 0; /* calculate x/y resolution, when browser_get_dpi() isn't available */ @@ -292,7 +295,8 @@ static bool ft_font_init(void) /* freetype library initialise */ error = FT_Init_FreeType( &library ); if (error) { - LOG("Freetype could not initialised (code %d)\n", error); + NSLOG(netsurf, INFO, + "Freetype could not initialised (code %d)\n", error); return false; } @@ -311,7 +315,9 @@ static bool ft_font_init(void) NULL, &ft_cmanager); if (error) { - LOG("Freetype could not initialise cache manager (code %d)\n", error); + NSLOG(netsurf, INFO, + "Freetype could not initialise cache manager (code %d)\n", + error); FT_Done_FreeType(library); return false; } @@ -330,7 +336,8 @@ static bool ft_font_init(void) FONT_PKG_PATH FONT_FILE_SANS ); if (font_faces[FONT_FACE_SANS_SERIF] == NULL) { - LOG("Could not find default font (code %d)\n", error); + NSLOG(netsurf, INFO, + "Could not find default font (code %d)\n", error); FTC_Manager_Done(ft_cmanager); FT_Done_FreeType(library); return false; @@ -688,7 +695,7 @@ int ctor_font_plotter_freetype( FONT_PLOTTER self ) self->draw_glyph = draw_glyph8; } - LOG("%s: %s\n", (char *)__FILE__, __FUNCTION__); + NSLOG(netsurf, INFO, "%s: %s\n", (char *)__FILE__, __FUNCTION__); if( !init ) { ft_font_init(); fontbmp = atari_bitmap_create(48, 48, 0); diff --git a/frontends/atari/plot/font_internal.c b/frontends/atari/plot/font_internal.c index 3575bc3e1..709697f74 100644 --- a/frontends/atari/plot/font_internal.c +++ b/frontends/atari/plot/font_internal.c @@ -96,7 +96,7 @@ int ctor_font_plotter_internal( FONT_PLOTTER self ) self->str_split = str_split; self->pixel_pos = pixel_pos; self->text = text; - LOG("%s: %s\n", (char *)__FILE__, __FUNCTION__); + NSLOG(netsurf, INFO, "%s: %s\n", (char *)__FILE__, __FUNCTION__); if( !init ) { vdih = self->vdi_handle; fontbmp = atari_bitmap_create(48, 48, 0); diff --git a/frontends/atari/plot/font_vdi.c b/frontends/atari/plot/font_vdi.c index ef5499207..556c08e82 100644 --- a/frontends/atari/plot/font_vdi.c +++ b/frontends/atari/plot/font_vdi.c @@ -70,7 +70,7 @@ int ctor_font_plotter_vdi( FONT_PLOTTER self ) self->str_split = str_split; self->pixel_pos = pixel_pos; self->text = text; - LOG("%s: %s\n", (char *)__FILE__, __FUNCTION__); + NSLOG(netsurf, INFO, "%s: %s\n", (char *)__FILE__, __FUNCTION__); if( !init ) { vdih = self->vdi_handle; } @@ -106,9 +106,9 @@ static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const c fx |= 1; vst_effects( self->vdi_handle, fx ); /* TODO: replace 90 with global dpi setting */ - //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 ); + //pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 ); //vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh); - pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 ); + pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 ); vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh); /* if(slen != utf8_bounded_length(str, length)){ @@ -148,10 +148,10 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const if( fstyle->weight > 450 ) fx |= 1; vst_effects( self->vdi_handle, fx ); - //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 ); + //pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 ); //vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh); - pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 ); + pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 ); vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh); *actual_x = 0; //*char_offset = 0; @@ -216,7 +216,7 @@ static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t * fstyle,const if( fstyle->weight > 450 ) fx |= 1; vst_effects(self->vdi_handle, fx); - pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 ); + pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 ); vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh); *actual_x = 0; *char_offset = 0; @@ -283,8 +283,8 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng /* TODO: netsurf uses 90 as default dpi ( somewhere defined in libcss), use that value or pass it as arg, to reduce netsurf dependency */ - //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 ); - pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 ); + //pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 ); + pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 ); plot_get_dimensions(&canvas); x += canvas.g_x; diff --git a/frontends/atari/plot/plot.c b/frontends/atari/plot/plot.c index 0a0d7a494..4935b1776 100644 --- a/frontends/atari/plot/plot.c +++ b/frontends/atari/plot/plot.c @@ -45,38 +45,31 @@ void vq_scrninfo(VdiHdl handle, short *work_out); struct s_view { - short x; /* drawing (screen) offset x */ - short y; /* drawing (screen) offset y */ - short w; /* width of buffer, not in sync with vis_w */ - short h; /* height of buffer, not in sync with vis_w */ - short vis_x; /* visible rectangle of the screen buffer */ - short vis_y; /* coords are relative to plot location */ - short vis_w; /* clipped to screen dimensions */ - short vis_h; /* visible width */ - struct rect abs_clipping; /* The toplevel clipping rectangle */ - struct rect clipping; /* actual clipping rectangle */ + short x; /**< drawing (screen) offset x */ + short y; /**< drawing (screen) offset y */ + short w; /**< width of buffer, not in sync with vis_w */ + short h; /**< height of buffer, not in sync with vis_w */ + short vis_x; /**< visible rectangle of the screen buffer */ + short vis_y; /**< coords are relative to plot location */ + short vis_w; /**< clipped to screen dimensions */ + short vis_h; /**< visible width */ + struct rect abs_clipping; /**< The toplevel clipping rectangle */ + struct rect clipping; /**< actual clipping rectangle */ float scale; }; -/* - * Capture the screen at x,y location - * param self instance - * param x absolute screen coords - * param y absolute screen coords - * param w width - * param h height - * - * This creates an snapshot in RGBA format (NetSurf's native format) +/** + * Garbage collection of the snapshot routine * + * this should be called after you are done with the data returned by + * snapshot_create don't access the screenshot after you called this + * function */ -static struct bitmap * snapshot_create(int x, int y, int w, int h); - -/* Garbage collection of the snapshot routine */ -/* this should be called after you are done with the data returned by snapshot_create */ -/* don't access the screenshot after you called this function */ static void snapshot_suspend(void); -/* destroy memory used by screenshot */ +/** + * destroy memory used by screenshot + */ static void snapshot_destroy(void); #ifdef WITH_8BPP_SUPPORT @@ -86,42 +79,78 @@ static char rgb_lookup[256][4]; short web_std_colors[6] = {0, 51, 102, 153, 204, 255}; unsigned short vdi_web_pal[216][3] = { - {0x000,0x000,0x000}, {0x0c8,0x000,0x000}, {0x190,0x000,0x000}, {0x258,0x000,0x000}, {0x320,0x000,0x000}, {0x3e8,0x000,0x000}, - {0x000,0x0c8,0x000}, {0x0c8,0x0c8,0x000}, {0x190,0x0c8,0x000}, {0x258,0x0c8,0x000}, {0x320,0x0c8,0x000}, {0x3e8,0x0c8,0x000}, - {0x000,0x190,0x000}, {0x0c8,0x190,0x000}, {0x190,0x190,0x000}, {0x258,0x190,0x000}, {0x320,0x190,0x000}, {0x3e8,0x190,0x000}, - {0x000,0x258,0x000}, {0x0c8,0x258,0x000}, {0x190,0x258,0x000}, {0x258,0x258,0x000}, {0x320,0x258,0x000}, {0x3e8,0x258,0x000}, - {0x000,0x320,0x000}, {0x0c8,0x320,0x000}, {0x190,0x320,0x000}, {0x258,0x320,0x000}, {0x320,0x320,0x000}, {0x3e8,0x320,0x000}, - {0x000,0x3e8,0x000}, {0x0c8,0x3e8,0x000}, {0x190,0x3e8,0x000}, {0x258,0x3e8,0x000}, {0x320,0x3e8,0x000}, {0x3e8,0x3e8,0x000}, - {0x000,0x000,0x0c8}, {0x0c8,0x000,0x0c8}, {0x190,0x000,0x0c8}, {0x258,0x000,0x0c8}, {0x320,0x000,0x0c8}, {0x3e8,0x000,0x0c8}, - {0x000,0x0c8,0x0c8}, {0x0c8,0x0c8,0x0c8}, {0x190,0x0c8,0x0c8}, {0x258,0x0c8,0x0c8}, {0x320,0x0c8,0x0c8}, {0x3e8,0x0c8,0x0c8}, - {0x000,0x190,0x0c8}, {0x0c8,0x190,0x0c8}, {0x190,0x190,0x0c8}, {0x258,0x190,0x0c8}, {0x320,0x190,0x0c8}, {0x3e8,0x190,0x0c8}, - {0x000,0x258,0x0c8}, {0x0c8,0x258,0x0c8}, {0x190,0x258,0x0c8}, {0x258,0x258,0x0c8}, {0x320,0x258,0x0c8}, {0x3e8,0x258,0x0c8}, - {0x000,0x320,0x0c8}, {0x0c8,0x320,0x0c8}, {0x190,0x320,0x0c8}, {0x258,0x320,0x0c8}, {0x320,0x320,0x0c8}, {0x3e8,0x320,0x0c8}, - {0x000,0x3e8,0x0c8}, {0x0c8,0x3e8,0x0c8}, {0x190,0x3e8,0x0c8}, {0x258,0x3e8,0x0c8}, {0x320,0x3e8,0x0c8}, {0x3e8,0x3e8,0x0c8}, - {0x000,0x000,0x190}, {0x0c8,0x000,0x190}, {0x190,0x000,0x190}, {0x258,0x000,0x190}, {0x320,0x000,0x190}, {0x3e8,0x000,0x190}, - {0x000,0x0c8,0x190}, {0x0c8,0x0c8,0x190}, {0x190,0x0c8,0x190}, {0x258,0x0c8,0x190}, {0x320,0x0c8,0x190}, {0x3e8,0x0c8,0x190}, - {0x000,0x190,0x190}, {0x0c8,0x190,0x190}, {0x190,0x190,0x190}, {0x258,0x190,0x190}, {0x320,0x190,0x190}, {0x3e8,0x190,0x190}, - {0x000,0x258,0x190}, {0x0c8,0x258,0x190}, {0x190,0x258,0x190}, {0x258,0x258,0x190}, {0x320,0x258,0x190}, {0x3e8,0x258,0x190}, - {0x000,0x320,0x190}, {0x0c8,0x320,0x190}, {0x190,0x320,0x190}, {0x258,0x320,0x190}, {0x320,0x320,0x190}, {0x3e8,0x320,0x190}, - {0x000,0x3e8,0x190}, {0x0c8,0x3e8,0x190}, {0x190,0x3e8,0x190}, {0x258,0x3e8,0x190}, {0x320,0x3e8,0x190}, {0x3e8,0x3e8,0x190}, - {0x000,0x000,0x258}, {0x0c8,0x000,0x258}, {0x190,0x000,0x258}, {0x258,0x000,0x258}, {0x320,0x000,0x258}, {0x3e8,0x000,0x258}, - {0x000,0x0c8,0x258}, {0x0c8,0x0c8,0x258}, {0x190,0x0c8,0x258}, {0x258,0x0c8,0x258}, {0x320,0x0c8,0x258}, {0x3e8,0x0c8,0x258}, - {0x000,0x190,0x258}, {0x0c8,0x190,0x258}, {0x190,0x190,0x258}, {0x258,0x190,0x258}, {0x320,0x190,0x258}, {0x3e8,0x190,0x258}, - {0x000,0x258,0x258}, {0x0c8,0x258,0x258}, {0x190,0x258,0x258}, {0x258,0x258,0x258}, {0x320,0x258,0x258}, {0x3e8,0x258,0x258}, - {0x000,0x320,0x258}, {0x0c8,0x320,0x258}, {0x190,0x320,0x258}, {0x258,0x320,0x258}, {0x320,0x320,0x258}, {0x3e8,0x320,0x258}, - {0x000,0x3e8,0x258}, {0x0c8,0x3e8,0x258}, {0x190,0x3e8,0x258}, {0x258,0x3e8,0x258}, {0x320,0x3e8,0x258}, {0x3e8,0x3e8,0x258}, - {0x000,0x000,0x320}, {0x0c8,0x000,0x320}, {0x190,0x000,0x320}, {0x258,0x000,0x320}, {0x320,0x000,0x320}, {0x3e8,0x000,0x320}, - {0x000,0x0c8,0x320}, {0x0c8,0x0c8,0x320}, {0x190,0x0c8,0x320}, {0x258,0x0c8,0x320}, {0x320,0x0c8,0x320}, {0x3e8,0x0c8,0x320}, - {0x000,0x190,0x320}, {0x0c8,0x190,0x320}, {0x190,0x190,0x320}, {0x258,0x190,0x320}, {0x320,0x190,0x320}, {0x3e8,0x190,0x320}, - {0x000,0x258,0x320}, {0x0c8,0x258,0x320}, {0x190,0x258,0x320}, {0x258,0x258,0x320}, {0x320,0x258,0x320}, {0x3e8,0x258,0x320}, - {0x000,0x320,0x320}, {0x0c8,0x320,0x320}, {0x190,0x320,0x320}, {0x258,0x320,0x320}, {0x320,0x320,0x320}, {0x3e8,0x320,0x320}, - {0x000,0x3e8,0x320}, {0x0c8,0x3e8,0x320}, {0x190,0x3e8,0x320}, {0x258,0x3e8,0x320}, {0x320,0x3e8,0x320}, {0x3e8,0x3e8,0x320}, - {0x000,0x000,0x3e8}, {0x0c8,0x000,0x3e8}, {0x190,0x000,0x3e8}, {0x258,0x000,0x3e8}, {0x320,0x000,0x3e8}, {0x3e8,0x000,0x3e8}, - {0x000,0x0c8,0x3e8}, {0x0c8,0x0c8,0x3e8}, {0x190,0x0c8,0x3e8}, {0x258,0x0c8,0x3e8}, {0x320,0x0c8,0x3e8}, {0x3e8,0x0c8,0x3e8}, - {0x000,0x190,0x3e8}, {0x0c8,0x190,0x3e8}, {0x190,0x190,0x3e8}, {0x258,0x190,0x3e8}, {0x320,0x190,0x3e8}, {0x3e8,0x190,0x3e8}, - {0x000,0x258,0x3e8}, {0x0c8,0x258,0x3e8}, {0x190,0x258,0x3e8}, {0x258,0x258,0x3e8}, {0x320,0x258,0x3e8}, {0x3e8,0x258,0x3e8}, - {0x000,0x320,0x3e8}, {0x0c8,0x320,0x3e8}, {0x190,0x320,0x3e8}, {0x258,0x320,0x3e8}, {0x320,0x320,0x3e8}, {0x3e8,0x320,0x3e8}, - {0x000,0x3e8,0x3e8}, {0x0c8,0x3e8,0x3e8}, {0x190,0x3e8,0x3e8}, {0x258,0x3e8,0x3e8}, {0x320,0x3e8,0x3e8}, {0x3e8,0x3e8,0x3e8} + {0x000,0x000,0x000}, {0x0c8,0x000,0x000}, {0x190,0x000,0x000}, + {0x258,0x000,0x000}, {0x320,0x000,0x000}, {0x3e8,0x000,0x000}, + {0x000,0x0c8,0x000}, {0x0c8,0x0c8,0x000}, {0x190,0x0c8,0x000}, + {0x258,0x0c8,0x000}, {0x320,0x0c8,0x000}, {0x3e8,0x0c8,0x000}, + {0x000,0x190,0x000}, {0x0c8,0x190,0x000}, {0x190,0x190,0x000}, + {0x258,0x190,0x000}, {0x320,0x190,0x000}, {0x3e8,0x190,0x000}, + {0x000,0x258,0x000}, {0x0c8,0x258,0x000}, {0x190,0x258,0x000}, + {0x258,0x258,0x000}, {0x320,0x258,0x000}, {0x3e8,0x258,0x000}, + {0x000,0x320,0x000}, {0x0c8,0x320,0x000}, {0x190,0x320,0x000}, + {0x258,0x320,0x000}, {0x320,0x320,0x000}, {0x3e8,0x320,0x000}, + {0x000,0x3e8,0x000}, {0x0c8,0x3e8,0x000}, {0x190,0x3e8,0x000}, + {0x258,0x3e8,0x000}, {0x320,0x3e8,0x000}, {0x3e8,0x3e8,0x000}, + {0x000,0x000,0x0c8}, {0x0c8,0x000,0x0c8}, {0x190,0x000,0x0c8}, + {0x258,0x000,0x0c8}, {0x320,0x000,0x0c8}, {0x3e8,0x000,0x0c8}, + {0x000,0x0c8,0x0c8}, {0x0c8,0x0c8,0x0c8}, {0x190,0x0c8,0x0c8}, + {0x258,0x0c8,0x0c8}, {0x320,0x0c8,0x0c8}, {0x3e8,0x0c8,0x0c8}, + {0x000,0x190,0x0c8}, {0x0c8,0x190,0x0c8}, {0x190,0x190,0x0c8}, + {0x258,0x190,0x0c8}, {0x320,0x190,0x0c8}, {0x3e8,0x190,0x0c8}, + {0x000,0x258,0x0c8}, {0x0c8,0x258,0x0c8}, {0x190,0x258,0x0c8}, + {0x258,0x258,0x0c8}, {0x320,0x258,0x0c8}, {0x3e8,0x258,0x0c8}, + {0x000,0x320,0x0c8}, {0x0c8,0x320,0x0c8}, {0x190,0x320,0x0c8}, + {0x258,0x320,0x0c8}, {0x320,0x320,0x0c8}, {0x3e8,0x320,0x0c8}, + {0x000,0x3e8,0x0c8}, {0x0c8,0x3e8,0x0c8}, {0x190,0x3e8,0x0c8}, + {0x258,0x3e8,0x0c8}, {0x320,0x3e8,0x0c8}, {0x3e8,0x3e8,0x0c8}, + {0x000,0x000,0x190}, {0x0c8,0x000,0x190}, {0x190,0x000,0x190}, + {0x258,0x000,0x190}, {0x320,0x000,0x190}, {0x3e8,0x000,0x190}, + {0x000,0x0c8,0x190}, {0x0c8,0x0c8,0x190}, {0x190,0x0c8,0x190}, + {0x258,0x0c8,0x190}, {0x320,0x0c8,0x190}, {0x3e8,0x0c8,0x190}, + {0x000,0x190,0x190}, {0x0c8,0x190,0x190}, {0x190,0x190,0x190}, + {0x258,0x190,0x190}, {0x320,0x190,0x190}, {0x3e8,0x190,0x190}, + {0x000,0x258,0x190}, {0x0c8,0x258,0x190}, {0x190,0x258,0x190}, + {0x258,0x258,0x190}, {0x320,0x258,0x190}, {0x3e8,0x258,0x190}, + {0x000,0x320,0x190}, {0x0c8,0x320,0x190}, {0x190,0x320,0x190}, + {0x258,0x320,0x190}, {0x320,0x320,0x190}, {0x3e8,0x320,0x190}, + {0x000,0x3e8,0x190}, {0x0c8,0x3e8,0x190}, {0x190,0x3e8,0x190}, + {0x258,0x3e8,0x190}, {0x320,0x3e8,0x190}, {0x3e8,0x3e8,0x190}, + {0x000,0x000,0x258}, {0x0c8,0x000,0x258}, {0x190,0x000,0x258}, + {0x258,0x000,0x258}, {0x320,0x000,0x258}, {0x3e8,0x000,0x258}, + {0x000,0x0c8,0x258}, {0x0c8,0x0c8,0x258}, {0x190,0x0c8,0x258}, + {0x258,0x0c8,0x258}, {0x320,0x0c8,0x258}, {0x3e8,0x0c8,0x258}, + {0x000,0x190,0x258}, {0x0c8,0x190,0x258}, {0x190,0x190,0x258}, + {0x258,0x190,0x258}, {0x320,0x190,0x258}, {0x3e8,0x190,0x258}, + {0x000,0x258,0x258}, {0x0c8,0x258,0x258}, {0x190,0x258,0x258}, + {0x258,0x258,0x258}, {0x320,0x258,0x258}, {0x3e8,0x258,0x258}, + {0x000,0x320,0x258}, {0x0c8,0x320,0x258}, {0x190,0x320,0x258}, + {0x258,0x320,0x258}, {0x320,0x320,0x258}, {0x3e8,0x320,0x258}, + {0x000,0x3e8,0x258}, {0x0c8,0x3e8,0x258}, {0x190,0x3e8,0x258}, + {0x258,0x3e8,0x258}, {0x320,0x3e8,0x258}, {0x3e8,0x3e8,0x258}, + {0x000,0x000,0x320}, {0x0c8,0x000,0x320}, {0x190,0x000,0x320}, + {0x258,0x000,0x320}, {0x320,0x000,0x320}, {0x3e8,0x000,0x320}, + {0x000,0x0c8,0x320}, {0x0c8,0x0c8,0x320}, {0x190,0x0c8,0x320}, + {0x258,0x0c8,0x320}, {0x320,0x0c8,0x320}, {0x3e8,0x0c8,0x320}, + {0x000,0x190,0x320}, {0x0c8,0x190,0x320}, {0x190,0x190,0x320}, + {0x258,0x190,0x320}, {0x320,0x190,0x320}, {0x3e8,0x190,0x320}, + {0x000,0x258,0x320}, {0x0c8,0x258,0x320}, {0x190,0x258,0x320}, + {0x258,0x258,0x320}, {0x320,0x258,0x320}, {0x3e8,0x258,0x320}, + {0x000,0x320,0x320}, {0x0c8,0x320,0x320}, {0x190,0x320,0x320}, + {0x258,0x320,0x320}, {0x320,0x320,0x320}, {0x3e8,0x320,0x320}, + {0x000,0x3e8,0x320}, {0x0c8,0x3e8,0x320}, {0x190,0x3e8,0x320}, + {0x258,0x3e8,0x320}, {0x320,0x3e8,0x320}, {0x3e8,0x3e8,0x320}, + {0x000,0x000,0x3e8}, {0x0c8,0x000,0x3e8}, {0x190,0x000,0x3e8}, + {0x258,0x000,0x3e8}, {0x320,0x000,0x3e8}, {0x3e8,0x000,0x3e8}, + {0x000,0x0c8,0x3e8}, {0x0c8,0x0c8,0x3e8}, {0x190,0x0c8,0x3e8}, + {0x258,0x0c8,0x3e8}, {0x320,0x0c8,0x3e8}, {0x3e8,0x0c8,0x3e8}, + {0x000,0x190,0x3e8}, {0x0c8,0x190,0x3e8}, {0x190,0x190,0x3e8}, + {0x258,0x190,0x3e8}, {0x320,0x190,0x3e8}, {0x3e8,0x190,0x3e8}, + {0x000,0x258,0x3e8}, {0x0c8,0x258,0x3e8}, {0x190,0x258,0x3e8}, + {0x258,0x258,0x3e8}, {0x320,0x258,0x3e8}, {0x3e8,0x258,0x3e8}, + {0x000,0x320,0x3e8}, {0x0c8,0x320,0x3e8}, {0x190,0x320,0x3e8}, + {0x258,0x320,0x3e8}, {0x320,0x320,0x3e8}, {0x3e8,0x320,0x3e8}, + {0x000,0x3e8,0x3e8}, {0x0c8,0x3e8,0x3e8}, {0x190,0x3e8,0x3e8}, + {0x258,0x3e8,0x3e8}, {0x320,0x3e8,0x3e8}, {0x3e8,0x3e8,0x3e8} }; #endif @@ -180,15 +209,16 @@ VdiHdl atari_plot_vdi_handle = -1; unsigned long atari_plot_flags; unsigned long atari_font_flags; -typedef bool (*bitmap_convert_fnc)( struct bitmap * img, int x, int y, - GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out ); +typedef bool (*bitmap_convert_fnc)(struct bitmap * img, int x, int y, GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out ); static bitmap_convert_fnc bitmap_convert; +/* exported interface documented in atari/plot.h */ const char* plot_err_str(int i) { - return(plot_error_codes[abs(i)]); + return (plot_error_codes[abs(i)]); } + /** * Set line drawing color by passing netsurf XBGR "colour" type. * @@ -200,21 +230,22 @@ inline static void vsl_rgbcolor(short vdih, colour cin) #ifdef WITH_8BPP_SUPPORT if( vdi_sysinfo.scr_bpp > 8 ) { #endif - RGB1000 c; /* a struct with three (RGB) shorts */ - rgb_to_vdi1000( (unsigned char*)&cin, &c); - vs_color(vdih, OFFSET_CUSTOM_COLOR, (short *)&c); - vsl_color(vdih, OFFSET_CUSTOM_COLOR); + RGB1000 c; /* a struct with three (RGB) shorts */ + rgb_to_vdi1000( (unsigned char*)&cin, &c); + vs_color(vdih, OFFSET_CUSTOM_COLOR, (short *)&c); + vsl_color(vdih, OFFSET_CUSTOM_COLOR); #ifdef WITH_8BPP_SUPPORT } else { - if( vdi_sysinfo.scr_bpp >= 4 ){ - vsl_color(vdih, RGB_TO_VDI(cin)); - } - else - vsl_color(vdih, BLACK); + if( vdi_sysinfo.scr_bpp >= 4 ){ + vsl_color(vdih, RGB_TO_VDI(cin)); + } + else + vsl_color(vdih, BLACK); } #endif } + /** * Set fill color by passing netsurf XBGR "colour" type. * @@ -226,23 +257,22 @@ inline static void vsf_rgbcolor(short vdih, colour cin) #ifdef WITH_8BPP_SUPPORT if( vdi_sysinfo.scr_bpp > 8 ) { #endif - RGB1000 c; /* a struct with three (RGB) shorts */ - rgb_to_vdi1000( (unsigned char*)&cin, &c); - vs_color( vdih, OFFSET_CUSTOM_COLOR, (short *)&c); - vsf_color( vdih, OFFSET_CUSTOM_COLOR ); + RGB1000 c; /* a struct with three (RGB) shorts */ + rgb_to_vdi1000( (unsigned char*)&cin, &c); + vs_color( vdih, OFFSET_CUSTOM_COLOR, (short *)&c); + vsf_color( vdih, OFFSET_CUSTOM_COLOR ); #ifdef WITH_8BPP_SUPPORT } else { - if( vdi_sysinfo.scr_bpp >= 4 ){ - vsf_color( vdih, RGB_TO_VDI(cin) ); - } - else - vsf_color( vdih, WHITE ); + if( vdi_sysinfo.scr_bpp >= 4 ){ + vsf_color( vdih, RGB_TO_VDI(cin) ); + } + else + vsf_color( vdih, WHITE ); } #endif } - /** * Get current visible coords */ @@ -255,7 +285,6 @@ inline static void plot_get_visible_grect(GRECT * out) } - /* calculate visible area of framebuffer in coords relative to framebuffer */ /* position */ /* result: */ @@ -280,24 +309,29 @@ inline static void update_visible_rect(void) common.g_h = frame.g_h = view.h; if (rc_intersect(&screen, &common)) { - view.vis_w = common.g_w; - view.vis_h = common.g_h; - if (view.x < screen.g_x) - view.vis_x = frame.g_w - common.g_w; - else - view.vis_x = 0; - if (view.y <screen.g_y) - view.vis_y = frame.g_h - common.g_h; - else - view.vis_y = 0; + view.vis_w = common.g_w; + view.vis_h = common.g_h; + if (view.x < screen.g_x) + view.vis_x = frame.g_w - common.g_w; + else + view.vis_x = 0; + if (view.y <screen.g_y) + view.vis_y = frame.g_h - common.g_h; + else + view.vis_y = 0; } else { - view.vis_w = view.vis_h = 0; - view.vis_x = view.vis_y = 0; + view.vis_w = view.vis_h = 0; + view.vis_x = view.vis_y = 0; } } -/* Returns the visible parts of the box (relative coords within framebuffer),*/ -/* relative to screen coords (normally starting at 0,0 ) */ + +/** + * Returns the visible parts of the box + * + * The returned values are relative coords within framebuffer, + * relative to screen coords (normally starting at 0,0 ) + */ inline static bool fbrect_to_screen(GRECT box, GRECT * ret) { GRECT out, vis, screen; @@ -314,14 +348,14 @@ inline static bool fbrect_to_screen(GRECT box, GRECT * ret) vis.g_h = view.h; if ( !rc_intersect( &screen, &vis ) ) { - return( false ); + return( false ); } vis.g_x = view.w - vis.g_w; vis.g_y = view.h - vis.g_h; /* clip box to visible region: */ if( !rc_intersect(&vis, &box) ) { - return( false ); + return( false ); } out.g_x = box.g_x + view.x; out.g_y = box.g_y + view.y; @@ -331,8 +365,12 @@ inline static bool fbrect_to_screen(GRECT box, GRECT * ret) return ( true ); } -/* copy an rectangle from the plot buffer to screen */ -/* because this is an on-screen plotter, this is an screen to screen copy. */ + +/** + * copy an rectangle from the plot buffer to screen + * + * because this is an on-screen plotter, this is an screen to screen copy. + */ bool plot_copy_rect(GRECT src, GRECT dst) { MFDB devmf; @@ -344,9 +382,9 @@ bool plot_copy_rect(GRECT src, GRECT dst) plot_get_visible_grect(&vis ); if( !rc_intersect(&vis, &src) ) - return(true); + return(true); if( !rc_intersect(&vis, &dst) ) - return(true); + return(true); src.g_x = view.x + src.g_x; src.g_y = view.y + src.g_y; @@ -384,23 +422,25 @@ bool plot_copy_rect(GRECT src, GRECT dst) return(true); } + /** * Fill the screen info structure. * * \param vdih The handle * \param[out] info The infor structure to fill. */ -static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) { - - unsigned long cookie_EdDI=0; /** \todo this long is being cast to a pointer */ +static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) +{ + /** \todo this long is being cast to a pointer */ + unsigned long cookie_EdDI=0; short out[300]; memset( info, 0, sizeof(struct s_vdi_sysinfo) ); info->vdi_handle = vdih; if ( tos_getcookie(C_EdDI, (long *)&cookie_EdDI) == C_NOTFOUND ) { - info->EdDiVersion = 0; + info->EdDiVersion = 0; } else { - info->EdDiVersion = EdDI_version( (void *)cookie_EdDI ); + info->EdDiVersion = EdDI_version( (void *)cookie_EdDI ); } memset( &out, 0, sizeof(short)*300 ); @@ -408,10 +448,10 @@ static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) { info->scr_w = out[0]+1; info->scr_h = out[1]+1; if( out[39] == 2 ) { - info->scr_bpp = 1; - info->colors = out[39]; + info->scr_bpp = 1; + info->colors = out[39]; } else { - info->colors = out[39]; + info->colors = out[39]; } memset( &out, 0, sizeof(short)*300 ); @@ -420,31 +460,31 @@ static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) { info->maxpolycoords = out[14]; info->maxintin = out[15]; if( out[30] & 1 ) { - info->rasterscale = true; + info->rasterscale = true; } else { - info->rasterscale = false; + info->rasterscale = false; } switch( info->scr_bpp ) { case 8: - info->pixelsize=1; - break; + info->pixelsize=1; + break; case 15: case 16: - info->pixelsize=2; - break; + info->pixelsize=2; + break; case 24: - info->pixelsize=3; - break; + info->pixelsize=3; + break; case 32: - info->pixelsize=4; - break; + info->pixelsize=4; + break; case 64: - info->pixelsize=8; - break; + info->pixelsize=8; + break; default: - info->pixelsize=1; - break; + info->pixelsize=1; + break; } info->pitch = info->scr_w * info->pixelsize; @@ -452,75 +492,75 @@ static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) { info->screensize = ( info->scr_w * info->pixelsize ) * info->scr_h; if( info->EdDiVersion >= EDDI_10 ) { - memset( &out, 0, sizeof(short)*300 ); - vq_scrninfo(vdih, (short*)&out); - info->vdiformat = out[0]; - info->clut = out[1]; - info->scr_bpp = out[2]; - info->hicolors = *((unsigned long*) &out[3]); - if( info->EdDiVersion >= EDDI_11 ) { - info->pitch = out[5]; - info->screen = (void *) *((unsigned long *) &out[6]); - } - - switch( info->clut ) { - - case VDI_CLUT_HARDWARE: { - - } - break; - - case VDI_CLUT_SOFTWARE: { - int component; /* red, green, blue, alpha, overlay */ - int num_bit; - unsigned short *tmp_p; - - /* We can build masks with info here */ - tmp_p = (unsigned short *) &out[16]; - for (component=0; component<5; component++) { - for (num_bit=0; num_bit<16; num_bit++) { - unsigned short val; - - val = *tmp_p++; - - if (val == 0xffff) { - continue; - } - - switch(component) { - case 0: - info->mask_r |= 1<< val; - break; - case 1: - info->mask_g |= 1<< val; - break; - case 2: - info->mask_b |= 1<< val; - break; - case 3: - info->mask_a |= 1<< val; - break; - } - } - } - } - - /* Remove lower green bits for Intel endian screen */ - if ((info->mask_g == ((7<<13)|3)) || (info->mask_g == ((7<<13)|7))) { - info->mask_g &= ~(7<<13); - } - break; - - case VDI_CLUT_NONE: - break; - } + memset( &out, 0, sizeof(short)*300 ); + vq_scrninfo(vdih, (short*)&out); + info->vdiformat = out[0]; + info->clut = out[1]; + info->scr_bpp = out[2]; + info->hicolors = *((unsigned long*) &out[3]); + if( info->EdDiVersion >= EDDI_11 ) { + info->pitch = out[5]; + info->screen = (void *) *((unsigned long *) &out[6]); + } + + switch( info->clut ) { + + case VDI_CLUT_HARDWARE: + break; + + case VDI_CLUT_SOFTWARE: + { + int component; /* red, green, blue, alpha, overlay */ + int num_bit; + unsigned short *tmp_p; + + /* We can build masks with info here */ + tmp_p = (unsigned short *) &out[16]; + for (component=0; component<5; component++) { + for (num_bit=0; num_bit<16; num_bit++) { + unsigned short val; + + val = *tmp_p++; + + if (val == 0xffff) { + continue; + } + + switch(component) { + case 0: + info->mask_r |= 1<< val; + break; + case 1: + info->mask_g |= 1<< val; + break; + case 2: + info->mask_b |= 1<< val; + break; + case 3: + info->mask_a |= 1<< val; + break; + } + } + } + } + + /* Remove lower green bits for Intel endian screen */ + if ((info->mask_g == ((7<<13)|3)) || + (info->mask_g == ((7<<13)|7))) { + info->mask_g &= ~(7<<13); + } + break; + + case VDI_CLUT_NONE: + break; + } } } -/* - Convert an RGB color to an VDI Color -*/ +/** + * Convert an RGB color to an VDI Color + */ inline void rgb_to_vdi1000(unsigned char * in, RGB1000 *out) { double r = ((double)in[3]/255); /* prozentsatz red */ @@ -532,6 +572,7 @@ inline void rgb_to_vdi1000(unsigned char * in, RGB1000 *out) return; } + inline void vdi1000_to_rgb(unsigned short * in, unsigned char * out) { double r = ((double)in[0]/1000); /* prozentsatz red */ @@ -548,7 +589,8 @@ inline void vdi1000_to_rgb(unsigned short * in, unsigned char * out) /** * Set pixel within an 8 bit VDI standard bitmap. */ -inline static void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned char val ) +inline static void +set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned char val ) { short * buf; short whichbit = (1<<(15-(x%16))); @@ -580,6 +622,7 @@ inline static void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned *buf = (val&(1<<7)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit)); } + /** * Read pixel from an 8 bit VDI standard bitmap. */ @@ -593,42 +636,42 @@ inline static unsigned char get_stdpx(MFDB * dst, int wdplanesz, int x, int y) buf += ((dst->fd_wdwidth*(y))+(x>>4)); if( *buf & whichbit ) - ret |= 1; + ret |= 1; buf += wdplanesz; if( *buf & whichbit ) - ret |= 2; + ret |= 2; buf += wdplanesz; if( *buf & whichbit ) - ret |= 4; + ret |= 4; buf += wdplanesz; if( *buf & whichbit ) - ret |= 8; + ret |= 8; buf += wdplanesz; if( *buf & whichbit ) - ret |= 16; + ret |= 16; buf += wdplanesz; if( *buf & whichbit ) - ret |= 32; + ret |= 32; buf += wdplanesz; if( *buf & whichbit ) - ret |= 64; + ret |= 64; buf += wdplanesz; if( *buf & whichbit ) - ret |= 128; + ret |= 128; return( ret ); } -/* - Convert an RGB color into an index into the 216 colors web pallette -*/ +/** + * Convert an RGB color into an index into the 216 colors web pallette + */ inline short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b) { short i; @@ -640,24 +683,24 @@ inline short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b) diff_b = abs(r-b); diff_c = abs(r-b); if( diff_a < 2 && diff_b < 2 && diff_c < 2 ) { - if( (r!=0XFF) && (g!=0XFF) && (b!=0XFF) ) { - if( ((r&0xF0)>>4) != 0 ) - //printf("conv gray: %x -> %d\n", ((r&0xF0)>>4) , (OFFSET_CUST_PAL) + ((r&0xF0)>>4) ); - return( (OFFSET_CUST_PAL - OFFSET_WEB_PAL) + ((r&0xF0)>>4) ); - } + if( (r!=0XFF) && (g!=0XFF) && (b!=0XFF) ) { + if( ((r&0xF0)>>4) != 0 ) + //printf("conv gray: %x -> %d\n", ((r&0xF0)>>4) , (OFFSET_CUST_PAL) + ((r&0xF0)>>4) ); + return( (OFFSET_CUST_PAL - OFFSET_WEB_PAL) + ((r&0xF0)>>4) ); + } } /* convert each 8bit color to 6bit web color: */ for( i=0; i<3; i++) { - if(0 == rgb[i] % web_std_colors[1] ) { - tval[i] = rgb[i] / web_std_colors[1]; - } else { - int pos = ((short)rgb[i] / web_std_colors[1]); - if( abs(rgb[i] - web_std_colors[pos]) > abs(rgb[i] - web_std_colors[pos+1]) ) - tval[i] = pos+1; - else - tval[i] = pos; - } + if(0 == rgb[i] % web_std_colors[1] ) { + tval[i] = rgb[i] / web_std_colors[1]; + } else { + int pos = ((short)rgb[i] / web_std_colors[1]); + if( abs(rgb[i] - web_std_colors[pos]) > abs(rgb[i] - web_std_colors[pos+1]) ) + tval[i] = pos+1; + else + tval[i] = pos; + } } return(tval[2]*36+tval[1]*6+tval[0]); } @@ -692,6 +735,7 @@ static void dump_vdi_info(short vdih) printf("};\n"); } + /** * Create an snapshot of the screen image in device format. */ @@ -702,29 +746,29 @@ static MFDB * snapshot_create_native_mfdb(int x, int y, int w, int h) /* allocate memory for the snapshot */ { - int scr_stride = MFDB_STRIDE( w ); - int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp ); - if(size_buf_scr == 0 ){ - /* init screen mfdb */ - buf_scr.fd_addr = malloc( scr_size ); - size_buf_scr = scr_size; - } else { - if( scr_size >size_buf_scr ) { - buf_scr.fd_addr = realloc( - buf_scr.fd_addr, scr_size - ); - size_buf_scr = scr_size; - } - } - if(buf_scr.fd_addr == NULL ) { - size_buf_scr = 0; - return( NULL ); - } - buf_scr.fd_nplanes = vdi_sysinfo.scr_bpp; - buf_scr.fd_w = scr_stride; - buf_scr.fd_h = h; - buf_scr.fd_wdwidth = scr_stride >> 4; - assert(buf_scr.fd_addr != NULL ); + int scr_stride = MFDB_STRIDE( w ); + int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp ); + if(size_buf_scr == 0 ){ + /* init screen mfdb */ + buf_scr.fd_addr = malloc( scr_size ); + size_buf_scr = scr_size; + } else { + if( scr_size >size_buf_scr ) { + buf_scr.fd_addr = realloc( + buf_scr.fd_addr, scr_size + ); + size_buf_scr = scr_size; + } + } + if(buf_scr.fd_addr == NULL ) { + size_buf_scr = 0; + return( NULL ); + } + buf_scr.fd_nplanes = vdi_sysinfo.scr_bpp; + buf_scr.fd_w = scr_stride; + buf_scr.fd_h = h; + buf_scr.fd_wdwidth = scr_stride >> 4; + assert(buf_scr.fd_addr != NULL ); } init_mfdb( 0, w, h, 0, &scr ); pxy[0] = x; @@ -736,18 +780,27 @@ static MFDB * snapshot_create_native_mfdb(int x, int y, int w, int h) pxy[6] = w-1; pxy[7] = h-1; vro_cpyfm( - atari_plot_vdi_handle, S_ONLY, (short*)&pxy, - &scr, &buf_scr - ); + atari_plot_vdi_handle, S_ONLY, (short*)&pxy, + &scr, &buf_scr + ); return( &buf_scr ); } -/* +/** * Create an snapshot of the screen in netsurf ABGR format + * + * This creates an snapshot in RGBA format (NetSurf's native format) + * + * Capture the screen at x,y location + * + * \param x absolute screen coords + * \param y absolute screen coords + * \param w width + * \param h height */ -static struct bitmap * snapshot_create(int x, int y, int w, int h) +static struct bitmap *snapshot_create(int x, int y, int w, int h) { int err; MFDB * native; @@ -764,37 +817,37 @@ static struct bitmap * snapshot_create(int x, int y, int w, int h) native = snapshot_create_native_mfdb(x, y, w, h ); if(vfmt.bits == 32 ) - goto no_copy; + goto no_copy; /* allocate buffer for result bitmap: */ if(buf_scr_compat == NULL ) { - buf_scr_compat = atari_bitmap_create(w, h, 0); + buf_scr_compat = atari_bitmap_create(w, h, 0); } else { - buf_scr_compat = atari_bitmap_realloc( w, h, - buf_scr_compat->bpp, - w *buf_scr_compat->bpp, - BITMAP_GROW, - buf_scr_compat ); + buf_scr_compat = atari_bitmap_realloc( w, h, + buf_scr_compat->bpp, + w *buf_scr_compat->bpp, + BITMAP_GROW, + buf_scr_compat ); } /* convert screen buffer to ns format: */ err = Hermes_ConverterRequest( hermes_cnv_h, - &vfmt, - &nsfmt - ); + &vfmt, + &nsfmt + ); assert( err != 0 ); err = Hermes_ConverterCopy( hermes_cnv_h, - native->fd_addr, - 0, /* x src coord of top left in pixel coords */ - 0, /* y src coord of top left in pixel coords */ - w, h, - native->fd_w * vdi_sysinfo.pixelsize, /* stride as bytes */ - buf_scr_compat->pixdata, - 0, /* x dst coord of top left in pixel coords */ - 0, /* y dst coord of top left in pixel coords */ - w, h, - atari_bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */ - ); + native->fd_addr, + 0, /* x src coord of top left in pixel coords */ + 0, /* y src coord of top left in pixel coords */ + w, h, + native->fd_w * vdi_sysinfo.pixelsize, /* stride as bytes */ + buf_scr_compat->pixdata, + 0, /* x dst coord of top left in pixel coords */ + 0, /* y dst coord of top left in pixel coords */ + w, h, + atari_bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */ + ); assert( err != 0 ); return( (struct bitmap * )buf_scr_compat ); @@ -808,59 +861,61 @@ no_copy: uint32_t row, col; for (row = 0; row<(uint32_t)h; row++) { - // fd_w matches stride! - uint32_t *rowptr = ((uint32_t*)native->fd_addr + ((row*native->fd_w))); - for (col=0; col<(uint32_t)w; col++) { - *(rowptr+col) = (*(rowptr+col)<<8); - } + // fd_w matches stride! + uint32_t *rowptr = ((uint32_t*)native->fd_addr + ((row*native->fd_w))); + for (col=0; col<(uint32_t)w; col++) { + *(rowptr+col) = (*(rowptr+col)<<8); + } } return( &snapshot ); } + /** * Notify the snapshot interface that the last snapshot is no longer in use. */ static void snapshot_suspend(void) { if(size_buf_scr > CONV_KEEP_LIMIT ) { - buf_scr.fd_addr = realloc( - buf_scr.fd_addr, CONV_KEEP_LIMIT - ); - if(buf_scr.fd_addr != NULL ) { - size_buf_scr = CONV_KEEP_LIMIT; - } else { - size_buf_scr = 0; - } + buf_scr.fd_addr = realloc( + buf_scr.fd_addr, CONV_KEEP_LIMIT + ); + if(buf_scr.fd_addr != NULL ) { + size_buf_scr = CONV_KEEP_LIMIT; + } else { + size_buf_scr = 0; + } } #ifdef WITH_8BPP_SUPPORT if(size_buf_std > CONV_KEEP_LIMIT ) { - buf_std.fd_addr = realloc( - buf_std.fd_addr, CONV_KEEP_LIMIT - ); - if(buf_std.fd_addr != NULL ) { - size_buf_std = CONV_KEEP_LIMIT; - } else { - size_buf_std = 0; - } + buf_std.fd_addr = realloc( + buf_std.fd_addr, CONV_KEEP_LIMIT + ); + if(buf_std.fd_addr != NULL ) { + size_buf_std = CONV_KEEP_LIMIT; + } else { + size_buf_std = 0; + } } #endif if(buf_scr_compat != NULL ) { - size_t bs = atari_bitmap_buffer_size(buf_scr_compat ); - if( bs > CONV_KEEP_LIMIT ) { - int w = 0; - int h = 1; - w = (CONV_KEEP_LIMIT /buf_scr_compat->bpp); - assert( CONV_KEEP_LIMIT == w*buf_scr_compat->bpp ); - buf_scr_compat = atari_bitmap_realloc( w, h, - buf_scr_compat->bpp, - CONV_KEEP_LIMIT, BITMAP_SHRINK,buf_scr_compat - ); - } + size_t bs = atari_bitmap_buffer_size(buf_scr_compat ); + if( bs > CONV_KEEP_LIMIT ) { + int w = 0; + int h = 1; + w = (CONV_KEEP_LIMIT /buf_scr_compat->bpp); + assert( CONV_KEEP_LIMIT == w*buf_scr_compat->bpp ); + buf_scr_compat = atari_bitmap_realloc( w, h, + buf_scr_compat->bpp, + CONV_KEEP_LIMIT, BITMAP_SHRINK,buf_scr_compat + ); + } } } + /** * Shut down the snapshot interface. */ @@ -869,7 +924,7 @@ static void snapshot_destroy(void) free(buf_scr.fd_addr); if( buf_scr_compat != NULL) { - atari_bitmap_destroy(buf_scr_compat); + atari_bitmap_destroy(buf_scr_compat); } buf_scr.fd_addr = NULL; @@ -890,17 +945,19 @@ inline static uint32_t ablend(uint32_t pixel, uint32_t scrpixel) pixel >>= 8; scrpixel >>= 8; rb = ((pixel & 0xFF00FF) * opacity + - (scrpixel & 0xFF00FF) * transp) >> 8; + (scrpixel & 0xFF00FF) * transp) >> 8; g = ((pixel & 0x00FF00) * opacity + - (scrpixel & 0x00FF00) * transp) >> 8; + (scrpixel & 0x00FF00) * transp) >> 8; return ((rb & 0xFF00FF) | (g & 0xFF00)) << 8; } -/* - Alpha blends an image, using one pixel as the background. - The bitmap receives the result. -*/ + +/** + * Alpha blends an image, using one pixel as the background. + * + * The bitmap receives the result. + */ inline static bool ablend_pixel(struct bitmap * img, uint32_t bg, GRECT * clip) { uint32_t * imgrow; @@ -909,22 +966,25 @@ inline static bool ablend_pixel(struct bitmap * img, uint32_t bg, GRECT * clip) img_stride= atari_bitmap_get_rowstride(img); for( img_y = 0; img_y < clip->g_h; img_y++) { - imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y)); - for( img_x = 0; img_x < clip->g_w; img_x++ ) { - imgrow[img_x] = ablend( imgrow[img_x], bg ); - } + imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y)); + for( img_x = 0; img_x < clip->g_w; img_x++ ) { + imgrow[img_x] = ablend( imgrow[img_x], bg ); + } } return(true); } -/* - Aplha blends the foreground image (img) onto the - background images (bg). The background receives the blended - image pixels. -*/ -inline static bool ablend_bitmap( struct bitmap * img, struct bitmap * bg, - GRECT * img_clip, GRECT * bg_clip ) +/** + * Aplha blends the foreground image onto thebackground images. + * + * The background receives the blended image pixels. + */ +inline static bool +ablend_bitmap(struct bitmap *img, + struct bitmap *bg, + GRECT *img_clip, + GRECT * bg_clip ) { uint32_t * imgrow; uint32_t * screenrow; @@ -935,29 +995,29 @@ inline static bool ablend_bitmap( struct bitmap * img, struct bitmap * bg, bg_stride = atari_bitmap_get_rowstride(bg); for( img_y = img_clip->g_y, bg_y = 0; bg_y < img_clip->g_h; bg_y++, img_y++) { - imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y)); - screenrow = (uint32_t *)(bg->pixdata + (bg_stride * bg_y)); - for( img_x = img_clip->g_x, bg_x = 0; bg_x < img_clip->g_w; bg_x++, img_x++ ) { - - // when the pixel isn't fully transparent,...: - if( (imgrow[img_x] & 0x0FF) != 0 ){ - screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]); - } - - // FIXME, maybe this loop would be faster??: - // --- - //if( (imgrow[img_x] & 0x0FF) != 0xFF ){ - // imgrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]); - //} - - // or maybe even this??? - // --- - //if( (imgrow[img_x] & 0x0FF) == 0xFF ){ - // screenrow[bg_x] = imgrow[img_x]; - //} else if( (imgrow[img_x] & 0x0FF) != 0x00 ) { - // screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]); - //} - } + imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y)); + screenrow = (uint32_t *)(bg->pixdata + (bg_stride * bg_y)); + for( img_x = img_clip->g_x, bg_x = 0; bg_x < img_clip->g_w; bg_x++, img_x++ ) { + + // when the pixel isn't fully transparent,...: + if( (imgrow[img_x] & 0x0FF) != 0 ){ + screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]); + } + + // FIXME, maybe this loop would be faster??: + // --- + //if( (imgrow[img_x] & 0x0FF) != 0xFF ){ + // imgrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]); + //} + + // or maybe even this??? + // --- + //if( (imgrow[img_x] & 0x0FF) == 0xFF ){ + // screenrow[bg_x] = imgrow[img_x]; + //} else if( (imgrow[img_x] & 0x0FF) != 0x00 ) { + // screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]); + //} + } } return(false); } @@ -972,30 +1032,30 @@ static MFDB * snapshot_create_std_mfdb(int x, int y, int w, int h) { /* allocate memory for the snapshot */ { - int scr_stride = MFDB_STRIDE( w ); - int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp ); - if(size_buf_std == 0 ){ - /* init screen mfdb */ - buf_std.fd_addr = malloc( scr_size ); - size_buf_std = scr_size; - } else { - if( scr_size >size_buf_std ) { - buf_std.fd_addr = realloc( - buf_std.fd_addr, scr_size - ); - size_buf_std = scr_size; - } - } - if(buf_std.fd_addr == NULL ) { - size_buf_std = 0; - return( NULL ); - } - buf_std.fd_nplanes = 8; - buf_std.fd_w = scr_stride; - buf_std.fd_h = h; - buf_std.fd_stand = 1; - buf_std.fd_wdwidth = scr_stride >> 4; - assert(buf_std.fd_addr != NULL ); + int scr_stride = MFDB_STRIDE( w ); + int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp ); + if(size_buf_std == 0 ){ + /* init screen mfdb */ + buf_std.fd_addr = malloc( scr_size ); + size_buf_std = scr_size; + } else { + if( scr_size >size_buf_std ) { + buf_std.fd_addr = realloc( + buf_std.fd_addr, scr_size + ); + size_buf_std = scr_size; + } + } + if(buf_std.fd_addr == NULL ) { + size_buf_std = 0; + return( NULL ); + } + buf_std.fd_nplanes = 8; + buf_std.fd_w = scr_stride; + buf_std.fd_h = h; + buf_std.fd_stand = 1; + buf_std.fd_wdwidth = scr_stride >> 4; + assert(buf_std.fd_addr != NULL ); } MFDB * native = snapshot_create_native_mfdb(x,y,w,h ); assert( native ); @@ -1004,6 +1064,7 @@ static MFDB * snapshot_create_std_mfdb(int x, int y, int w, int h) return( &buf_std ); } + /** * Convert an bitmap to an 8 bit device dependant MFDB * \param img the bitmap (only tested with 32bit bitmaps) @@ -1015,9 +1076,14 @@ static MFDB * snapshot_create_std_mfdb(int x, int y, int w, int h) * \param out receives the converted bitmap (still owned by the plot API) * */ -static bool bitmap_convert_8(struct bitmap * img, int x, - int y, GRECT * clip, uint32_t bg, uint32_t flags, - MFDB *out ) +static bool +bitmap_convert_8(struct bitmap *img, + int x, + int y, + GRECT *clip, + uint32_t bg, + uint32_t flags, + MFDB *out) { MFDB native; MFDB stdform; @@ -1029,11 +1095,11 @@ static bool bitmap_convert_8(struct bitmap * img, int x, bool opaque = atari_bitmap_get_opaque( img ); if( opaque == false ){ - if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0) - && - ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){ - opaque = true; - } + if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0) + && + ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){ + opaque = true; + } } assert( clip->g_h > 0 ); @@ -1046,53 +1112,53 @@ static bool bitmap_convert_8(struct bitmap * img, int x, // the bitmap is fully opaque if( (opaque == true) || (flags & BITMAPF_BUFFER_NATIVE ) ){ - if( img->converted == true ){ - *out = img->native; - return( 0 ); - } - if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){ - cache = true; - } + if( img->converted == true ){ + *out = img->native; + return( 0 ); + } + if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){ + cache = true; + } } if( ( flags & BITMAPF_MONOGLYPH ) != 0 ){ - assert(cache == false); + assert(cache == false); } /* (re)allocate buffer for out image: */ /* altough the buffer is named "buf_packed" on 8bit systems */ /* it's not... */ if( cache == false ){ - // the size of the output will match the size of the clipping: - dststride = MFDB_STRIDE( clip->g_w ); - dstsize = ( ((dststride >> 3) * clip->g_h) * atari_plot_bpp_virt); - if (dstsize > size_buf_packed) { - int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1; - void *buf; - if (buf_packed == NULL) { - buf = malloc( blocks * CONV_BLOCK_SIZE); - } else { - buf = realloc(buf_packed, blocks * CONV_BLOCK_SIZE); - } - if (buf == NULL) { - return( 0-ERR_NO_MEM ); - } - buf_packed = buf; - size_buf_packed = blocks * CONV_BLOCK_SIZE; - } - native.fd_addr = buf_packed; + // the size of the output will match the size of the clipping: + dststride = MFDB_STRIDE( clip->g_w ); + dstsize = ( ((dststride >> 3) * clip->g_h) * atari_plot_bpp_virt); + if (dstsize > size_buf_packed) { + int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1; + void *buf; + if (buf_packed == NULL) { + buf = malloc( blocks * CONV_BLOCK_SIZE); + } else { + buf = realloc(buf_packed, blocks * CONV_BLOCK_SIZE); + } + if (buf == NULL) { + return( 0-ERR_NO_MEM ); + } + buf_packed = buf; + size_buf_packed = blocks * CONV_BLOCK_SIZE; + } + native.fd_addr = buf_packed; } else { - // the output image will be completly saved, so size of the output - // image will match the input image size. - dststride = MFDB_STRIDE( bw ); - dstsize = ( ((dststride >> 3) * bh) * atari_plot_bpp_virt); - assert( out->fd_addr == NULL ); - native.fd_addr = malloc( dstsize ); - if (native.fd_addr == NULL){ - if (scrbuf != NULL) - atari_bitmap_destroy(scrbuf); - return( 0-ERR_NO_MEM ); - } + // the output image will be completly saved, so size of the output + // image will match the input image size. + dststride = MFDB_STRIDE( bw ); + dstsize = ( ((dststride >> 3) * bh) * atari_plot_bpp_virt); + assert( out->fd_addr == NULL ); + native.fd_addr = malloc( dstsize ); + if (native.fd_addr == NULL){ + if (scrbuf != NULL) + atari_bitmap_destroy(scrbuf); + return( 0-ERR_NO_MEM ); + } } @@ -1103,29 +1169,29 @@ static bool bitmap_convert_8(struct bitmap * img, int x, */ // realloc mem for stdform if( opaque == false ){ - // point image to snapshot buffer, otherwise allocate mem - MFDB * bg = snapshot_create_std_mfdb(x, y, clip->g_w, clip->g_h); - stdform.fd_addr = bg->fd_addr; - bh = clip->g_h; + // point image to snapshot buffer, otherwise allocate mem + MFDB * bg = snapshot_create_std_mfdb(x, y, clip->g_w, clip->g_h); + stdform.fd_addr = bg->fd_addr; + bh = clip->g_h; } else { - if (dstsize > size_buf_planar) { - int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1; - void *buf; - if (buf_planar == NULL) { - buf = malloc(blocks * CONV_BLOCK_SIZE); - } else { - buf = realloc(buf_planar, blocks * CONV_BLOCK_SIZE); - } - if (buf == NULL ) { - if (cache) { - free(native.fd_addr); - } - return( 0-ERR_NO_MEM ); - } - buf_planar = buf; - size_buf_planar = blocks * CONV_BLOCK_SIZE; - } - stdform.fd_addr = buf_planar; + if (dstsize > size_buf_planar) { + int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1; + void *buf; + if (buf_planar == NULL) { + buf = malloc(blocks * CONV_BLOCK_SIZE); + } else { + buf = realloc(buf_planar, blocks * CONV_BLOCK_SIZE); + } + if (buf == NULL ) { + if (cache) { + free(native.fd_addr); + } + return( 0-ERR_NO_MEM ); + } + buf_planar = buf; + size_buf_planar = blocks * CONV_BLOCK_SIZE; + } + stdform.fd_addr = buf_planar; } stdform.fd_w = dststride; stdform.fd_h = bh; @@ -1143,67 +1209,67 @@ static bool bitmap_convert_8(struct bitmap * img, int x, int wdplanesize = stdform.fd_wdwidth*stdform.fd_h; if( opaque == false ){ - // apply transparency and convert to vdi std format - unsigned long bgcol = 0; - unsigned char prev_col = 0; - for( y=0; y<clip->g_h; y++ ){ - row = (uint32_t *)(img->pixdata + (img_stride * (y+clip->g_y))); - for( x=0; x<clip->g_w; x++ ){ - pixel = row[x+clip->g_x]; - if( (pixel&0xFF) == 0 ){ - continue; - } - if( (pixel&0xFF) < 0xF0 ){ - col = get_stdpx( &stdform, wdplanesize,x,y ); - if( (col != prev_col) || (y == 0) ) - bgcol = (((rgb_lookup[col][2] << 16) | (rgb_lookup[col][1] << 8) | (rgb_lookup[col][0]))<<8); - if( prev_col != col || prev_pixel != pixel ){ - prev_col = col; - pixel = ablend( pixel, bgcol ); - prev_pixel = pixel; - pixel = pixel >> 8; - /* convert pixel value to vdi color index: */ - col = ( ((pixel&0xFF)<<16) - | (pixel&0xFF00) - | ((pixel&0xFF0000)>>16) ); - val = RGB_TO_VDI( col ); - } - set_stdpx( &stdform, wdplanesize, x, y, val ); - } else { - if( pixel != prev_pixel ){ - /* convert pixel value to vdi color index: */ - pixel = pixel >> 8; - col = ( ((pixel&0xFF)<<16) - | (pixel&0xFF00) - | ((pixel&0xFF0000)>>16) ); - val = RGB_TO_VDI( col ); - prev_pixel = pixel; - } - set_stdpx( &stdform, wdplanesize, x, y, val ); - } - } - } - // adjust output position: - clip->g_x = 0; - clip->g_y = 0; + // apply transparency and convert to vdi std format + unsigned long bgcol = 0; + unsigned char prev_col = 0; + for( y=0; y<clip->g_h; y++ ){ + row = (uint32_t *)(img->pixdata + (img_stride * (y+clip->g_y))); + for( x=0; x<clip->g_w; x++ ){ + pixel = row[x+clip->g_x]; + if( (pixel&0xFF) == 0 ){ + continue; + } + if( (pixel&0xFF) < 0xF0 ){ + col = get_stdpx( &stdform, wdplanesize,x,y ); + if( (col != prev_col) || (y == 0) ) + bgcol = (((rgb_lookup[col][2] << 16) | (rgb_lookup[col][1] << 8) | (rgb_lookup[col][0]))<<8); + if( prev_col != col || prev_pixel != pixel ){ + prev_col = col; + pixel = ablend( pixel, bgcol ); + prev_pixel = pixel; + pixel = pixel >> 8; + /* convert pixel value to vdi color index: */ + col = ( ((pixel&0xFF)<<16) + | (pixel&0xFF00) + | ((pixel&0xFF0000)>>16) ); + val = RGB_TO_VDI( col ); + } + set_stdpx( &stdform, wdplanesize, x, y, val ); + } else { + if( pixel != prev_pixel ){ + /* convert pixel value to vdi color index: */ + pixel = pixel >> 8; + col = ( ((pixel&0xFF)<<16) + | (pixel&0xFF00) + | ((pixel&0xFF0000)>>16) ); + val = RGB_TO_VDI( col ); + prev_pixel = pixel; + } + set_stdpx( &stdform, wdplanesize, x, y, val ); + } + } + } + // adjust output position: + clip->g_x = 0; + clip->g_y = 0; } else { - // convert the whole image data to vdi std format. - for( y=0; y < bh; y++ ){ - row = (uint32_t *)(img->pixdata + (img_stride * y)); - for( x=0; x < bw; x++ ){ - pixel = row[x]; - if( pixel != prev_pixel ){ - /* convert pixel value to vdi color index: */ - pixel = pixel >> 8; - col = ( ((pixel&0xFF)<<16) - | (pixel&0xFF00) - | ((pixel&0xFF0000)>>16) ); - val = RGB_TO_VDI( col ); - prev_pixel = pixel; - } - set_stdpx( &stdform, wdplanesize, x, y, val ); - } - } + // convert the whole image data to vdi std format. + for( y=0; y < bh; y++ ){ + row = (uint32_t *)(img->pixdata + (img_stride * y)); + for( x=0; x < bw; x++ ){ + pixel = row[x]; + if( pixel != prev_pixel ){ + /* convert pixel value to vdi color index: */ + pixel = pixel >> 8; + col = ( ((pixel&0xFF)<<16) + | (pixel&0xFF00) + | ((pixel&0xFF0000)>>16) ); + val = RGB_TO_VDI( col ); + prev_pixel = pixel; + } + set_stdpx( &stdform, wdplanesize, x, y, val ); + } + } } // convert into native format: @@ -1216,8 +1282,8 @@ static bool bitmap_convert_8(struct bitmap * img, int x, vr_trnfm(atari_plot_vdi_handle, &stdform, &native ); *out = native; if( cache == true ){ - img->native = native; - img->converted = true; + img->native = native; + img->converted = true; } return(0); @@ -1225,24 +1291,30 @@ static bool bitmap_convert_8(struct bitmap * img, int x, #endif -/* - * +/** * Convert bitmap to the native screen format - * img: the bitmap - * x: coordinate where the bitmap REGION (described in clip) + * + * \param img the bitmap + * \param x coordinate where the bitmap REGION (described in clip) * shall be drawn (screen coords) - * y: coordinate where the bitmap REGION (described in clip) + * \param y coordinate where the bitmap REGION (described in clip) * shall be drawn (screen coords) - * clip: which area of the bitmap shall be drawn - * bg: background color - * flags: blit flags - * out: the result MFDB + * \param clip which area of the bitmap shall be drawn + * \param bg background color + * \param flags blit flags + * \param out the result MFDB */ -static bool bitmap_convert_tc(struct bitmap * img, int x, int y, - GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out ) +static bool +bitmap_convert_tc(struct bitmap *img, + int x, + int y, + GRECT *clip, + uint32_t bg, + uint32_t flags, + MFDB *out) { - int dststride; /* stride of dest. image */ - int dstsize; /* size of dest. in byte */ + int dststride; /* stride of dest. image */ + int dstsize; /* size of dest. in byte */ int err; int bw, bh; struct bitmap * scrbuf = NULL; @@ -1250,15 +1322,14 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y, bool cache = ( flags & BITMAPF_BUFFER_NATIVE ); bool opaque = atari_bitmap_get_opaque( img ); - if( opaque == false ){ - if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0) - && - ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){ - opaque = true; - } + if (opaque == false ) { + if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0) + && + ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){ + opaque = true; + } } - assert( clip->g_h > 0 ); assert( clip->g_w > 0 ); @@ -1277,80 +1348,80 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y, // toolbar buttons right now. if( (opaque == true) || (flags & BITMAPF_BUFFER_NATIVE ) ){ - if( img->converted == true ){ - *out = img->native; - return( 0 ); - } - if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){ - cache = true; - } + if( img->converted == true ){ + *out = img->native; + return( 0 ); + } + if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){ + cache = true; + } } /* rem. if eddi xy is installed, we could directly access the screen! */ /* apply transparency to the image: */ if (( opaque == false )) { - /* copy the screen to an temp buffer: */ - if ((flags & BITMAPF_BUFFER_NATIVE) == 0) { - scrbuf = snapshot_create(x, y, clip->g_w, clip->g_h); - if( scrbuf != NULL ) { - - assert( clip->g_w <= bw ); - assert( clip->g_h <= bh ); - - // copy blended pixels to the screen buffer: - ablend_bitmap( img, scrbuf, clip, NULL ); - /* adjust size which gets converted: */ - bw = clip->g_w; - bh = clip->g_h; - /* adjust output position: */ - clip->g_x = 0; - clip->g_y = 0; - /* set the source of conversion: */ - source = scrbuf; - } - } else { - /* - The whole bitmap can be transformed to an mfdb - (and get's cached) - */ - GRECT region = { 0, 0, bw, bh }; - ablend_pixel( img, bg, ®ion ); - source = img; - } + /* copy the screen to an temp buffer: */ + if ((flags & BITMAPF_BUFFER_NATIVE) == 0) { + scrbuf = snapshot_create(x, y, clip->g_w, clip->g_h); + if( scrbuf != NULL ) { + + assert( clip->g_w <= bw ); + assert( clip->g_h <= bh ); + + // copy blended pixels to the screen buffer: + ablend_bitmap( img, scrbuf, clip, NULL ); + /* adjust size which gets converted: */ + bw = clip->g_w; + bh = clip->g_h; + /* adjust output position: */ + clip->g_x = 0; + clip->g_y = 0; + /* set the source of conversion: */ + source = scrbuf; + } + } else { + /* + The whole bitmap can be transformed to an mfdb + (and get's cached) + */ + GRECT region = { 0, 0, bw, bh }; + ablend_pixel( img, bg, ®ion ); + source = img; + } } else { - source = img; + source = img; } /* (re)allocate buffer for converted image: */ dststride = MFDB_STRIDE(bw); dstsize = ( ((dststride >> 3) * bh) * atari_plot_bpp_virt ); if (cache == false) { - /* ensure cache buffer is large enough */ - if (dstsize > size_buf_packed) { - int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1; - void *buf; - if (buf_packed == NULL) { - buf = malloc(blocks * CONV_BLOCK_SIZE); - } else { - buf = realloc(buf_packed, blocks * CONV_BLOCK_SIZE); - } - if (buf == NULL ) { - if (scrbuf != NULL) { - atari_bitmap_destroy(scrbuf); - } - return( 0-ERR_NO_MEM ); - } - buf_packed = buf; - size_buf_packed = blocks * CONV_BLOCK_SIZE; - } - out->fd_addr = buf_packed; + /* ensure cache buffer is large enough */ + if (dstsize > size_buf_packed) { + int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1; + void *buf; + if (buf_packed == NULL) { + buf = malloc(blocks * CONV_BLOCK_SIZE); + } else { + buf = realloc(buf_packed, blocks * CONV_BLOCK_SIZE); + } + if (buf == NULL ) { + if (scrbuf != NULL) { + atari_bitmap_destroy(scrbuf); + } + return( 0-ERR_NO_MEM ); + } + buf_packed = buf; + size_buf_packed = blocks * CONV_BLOCK_SIZE; + } + out->fd_addr = buf_packed; } else { - assert( out->fd_addr == NULL ); - out->fd_addr = (void*)malloc( dstsize ); - if( out->fd_addr == NULL ){ - if( scrbuf != NULL ) - atari_bitmap_destroy( scrbuf ); - return( 0-ERR_NO_MEM ); - } + assert( out->fd_addr == NULL ); + out->fd_addr = (void*)malloc( dstsize ); + if( out->fd_addr == NULL ){ + if( scrbuf != NULL ) + atari_bitmap_destroy( scrbuf ); + return( 0-ERR_NO_MEM ); + } } out->fd_w = dststride; @@ -1361,10 +1432,10 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y, out->fd_r1 = out->fd_r2 = out->fd_r3 = 0; err = Hermes_ConverterRequest( - hermes_cnv_h, - &nsfmt, - &vfmt - ); + hermes_cnv_h, + &nsfmt, + &vfmt + ); assert( err != 0 ); // FIXME: here we can use the same optimization which is used for @@ -1372,43 +1443,44 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y, /* convert image to virtual format: */ err = Hermes_ConverterCopy( hermes_cnv_h, - source->pixdata, - 0, /* x src coord of top left in pixel coords */ - 0, /* y src coord of top left in pixel coords */ - bw, bh, - source->rowstride, /* stride as bytes */ - out->fd_addr, - 0, /* x dst coord of top left in pixel coords */ - 0, /* y dst coord of top left in pixel coords */ - bw, bh, - (dststride >> 3) * atari_plot_bpp_virt /* stride as bytes */ - ); + source->pixdata, + 0, /* x src coord of top left in pixel coords */ + 0, /* y src coord of top left in pixel coords */ + bw, bh, + source->rowstride, /* stride as bytes */ + out->fd_addr, + 0, /* x dst coord of top left in pixel coords */ + 0,/* y dst coord of top left in pixel coords */ + bw, bh, + (dststride >> 3) * atari_plot_bpp_virt /* stride as bytes */ + ); assert( err != 0 ); if( cache == true ){ - img->native = *out; - img->converted = true; + img->native = *out; + img->converted = true; } return( 0 ); } + inline static void convert_bitmap_done(void) { if (size_buf_packed > CONV_KEEP_LIMIT) { - void *buf; - /* free the mem if it was an large allocation ... */ - buf = realloc(buf_packed, CONV_KEEP_LIMIT); - if (buf != NULL) { - buf_packed = buf; - size_buf_packed = CONV_KEEP_LIMIT; - } + void *buf; + /* free the mem if it was an large allocation ... */ + buf = realloc(buf_packed, CONV_KEEP_LIMIT); + if (buf != NULL) { + buf_packed = buf; + size_buf_packed = CONV_KEEP_LIMIT; + } } } bool plot_blit_bitmap(struct bitmap * bmp, int x, int y, - unsigned long bg, unsigned long flags ) + unsigned long bg, unsigned long flags ) { MFDB src_mf; MFDB scrmf; @@ -1431,7 +1503,7 @@ bool plot_blit_bitmap(struct bitmap * bmp, int x, int y, clip.g_h = view.clipping.y1 - view.clipping.y0; if( !rc_intersect( &clip, &off) ) { - return(true); + return(true); } // clip the visible rectangle of the plot area @@ -1439,7 +1511,7 @@ bool plot_blit_bitmap(struct bitmap * bmp, int x, int y, // screen region: plot_get_visible_grect(&vis); if( !rc_intersect( &vis, &off) ) { - return(true); + return(true); } screen_x = view.x + off.g_x; @@ -1453,8 +1525,8 @@ bool plot_blit_bitmap(struct bitmap * bmp, int x, int y, /* Convert the Bitmap to native screen format - ready for output. */ /* This includes blending transparent pixels: */ if (bitmap_convert(bmp, screen_x, screen_y, &off, bg, flags, &src_mf) - != 0 ) { - return(true); + != 0 ) { + return(true); } // setup the src region: @@ -1475,8 +1547,9 @@ bool plot_blit_bitmap(struct bitmap * bmp, int x, int y, return(true); } + bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor, - uint32_t flags) + uint32_t flags) { MFDB screen; // MFDB tran; @@ -1487,7 +1560,7 @@ bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor, plot_get_clip_grect(&off); if( rc_intersect(loc, &off) == 0 ){ - return( 1 ); + return( 1 ); } init_mfdb( 0, loc->g_w, loc->g_h, 0, &screen ); @@ -1527,53 +1600,49 @@ bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor, if( flags & PLOT_FLAG_TRANS && src->fd_nplanes == 1){ - vrt_cpyfm(atari_plot_vdi_handle, MD_REPLACE/*MD_TRANS*/, (short*)pxy, src, &screen, (short*)&c); + vrt_cpyfm(atari_plot_vdi_handle, MD_REPLACE/*MD_TRANS*/, (short*)pxy, src, &screen, (short*)&c); } else { - /* this method only plots transparent bitmaps, right now... */ + /* this method only plots transparent bitmaps, right now... */ } return( 1 ); } -/* - Init screen and font driver objects. - Returns non-zero value > -1 when the objects could be succesfully created. - Returns value < 0 to indicate an error -*/ -int plot_init(char * fdrvrname) +/* exported interface documented in atari/plot.h */ +int plot_init(const struct redraw_context *ctx, char *fdrvrname) { - - GRECT loc_pos= {0,0,360,400}; + GRECT loc_pos = { 0, 0, 360, 400 }; int err=0; if( nsoption_int(atari_dither) == 1) - atari_plot_flags |= PLOT_FLAG_DITHER; + atari_plot_flags |= PLOT_FLAG_DITHER; if( nsoption_int(atari_transparency) == 1 ) - atari_plot_flags |= PLOT_FLAG_TRANS; + atari_plot_flags |= PLOT_FLAG_TRANS; if( nsoption_int(atari_font_monochrom) == 1 ) - atari_font_flags |= FONTPLOT_FLAG_MONOGLYPH; + atari_font_flags |= FONTPLOT_FLAG_MONOGLYPH; - if(atari_plot_vdi_handle == -1) { + if (atari_plot_vdi_handle == -1) { - short dummy; - short work_in[12] = {Getrez()+2,1,1,1,1,1,1,1,1,1,2,1}; - short work_out[57]; - atari_plot_vdi_handle=graf_handle(&dummy, &dummy, &dummy, &dummy); - v_opnvwk(work_in, &atari_plot_vdi_handle, work_out); - LOG("Plot VDI handle: %d", atari_plot_vdi_handle); + short dummy; + short work_in[12] = {Getrez()+2,1,1,1,1,1,1,1,1,1,2,1}; + short work_out[57]; + atari_plot_vdi_handle=graf_handle(&dummy, &dummy, &dummy, &dummy); + v_opnvwk(work_in, &atari_plot_vdi_handle, work_out); + NSLOG(netsurf, INFO, "Plot VDI handle: %d", atari_plot_vdi_handle); } read_vdi_sysinfo(atari_plot_vdi_handle, &vdi_sysinfo); if(verbose_log) { - dump_vdi_info(atari_plot_vdi_handle) ; - dump_font_drivers(); + dump_vdi_info(atari_plot_vdi_handle) ; + dump_font_drivers(); } fplotter = new_font_plotter(atari_plot_vdi_handle, fdrvrname, - atari_font_flags, &err); - if(err) { - const char * desc = plot_err_str(err); - LOG("Unable to load font plotter %s -> %s", fdrvrname, desc ); - die("font plotter"); + atari_font_flags, &err); + if (err) { + const char * desc = plot_err_str(err); + NSLOG(netsurf, INFO, "Unable to load font plotter %s -> %s", + fdrvrname, desc); + die("font plotter"); } memset(&view, 0, sizeof(struct s_view)); @@ -1587,9 +1656,9 @@ int plot_init(char * fdrvrname) buf_packed = NULL; buf_planar = NULL; if( vdi_sysinfo.vdiformat == VDI_FORMAT_PACK ) { - atari_plot_bpp_virt = vdi_sysinfo.scr_bpp; + atari_plot_bpp_virt = vdi_sysinfo.scr_bpp; } else { - atari_plot_bpp_virt = 8; + atari_plot_bpp_virt = 8; } plot_set_scale(1.0); @@ -1600,7 +1669,7 @@ int plot_init(char * fdrvrname) clip.y0 = 0; clip.x1 = view.w; clip.y1 = view.h; - plot_clip(&clip); + ctx->plot->clip(ctx, &clip); assert(Hermes_Init()); @@ -1610,38 +1679,38 @@ int plot_init(char * fdrvrname) /* Setup color lookup tables and palette */ unsigned char rgbcol[4]; if( vdi_sysinfo.scr_bpp <= 8 ){ - unsigned char graytone=0; - int i; - for( i=0; i<=255; i++ ) { - - // get the current color and save it for restore: - vq_color(atari_plot_vdi_handle, i, 1, (unsigned short*)&sys_pal[i][0] ); - if( i<OFFSET_WEB_PAL ) { - pal[i][0] = sys_pal[i][0]; - pal[i][1] = sys_pal[i][1]; - pal[i][2] = sys_pal[i][2]; - } else if( vdi_sysinfo.scr_bpp >= 8 ) { - if ( i < OFFSET_CUST_PAL ){ - pal[i][0] = vdi_web_pal[i-OFFSET_WEB_PAL][0]; - pal[i][1] = vdi_web_pal[i-OFFSET_WEB_PAL][1]; - pal[i][2] = vdi_web_pal[i-OFFSET_WEB_PAL][2]; - //set the new palette color to websafe value: - vs_color(atari_plot_vdi_handle, i, &pal[i][0]); - } - if( i >= OFFSET_CUST_PAL && i<OFFSET_CUST_PAL+16 ) { - /* here we define 20 additional gray colors... */ - rgbcol[1] = rgbcol[2] = rgbcol[3] = ((graytone&0x0F) << 4); - rgb_to_vdi1000( &rgbcol[0], &pal[i][0] ); - vs_color(atari_plot_vdi_handle, i, &pal[i][0]); - graytone++; - } - - } - vdi1000_to_rgb( &pal[i][0], &rgb_lookup[i][0] ); - } + unsigned char graytone=0; + int i; + for( i=0; i<=255; i++ ) { + + // get the current color and save it for restore: + vq_color(atari_plot_vdi_handle, i, 1, (unsigned short*)&sys_pal[i][0] ); + if( i<OFFSET_WEB_PAL ) { + pal[i][0] = sys_pal[i][0]; + pal[i][1] = sys_pal[i][1]; + pal[i][2] = sys_pal[i][2]; + } else if( vdi_sysinfo.scr_bpp >= 8 ) { + if ( i < OFFSET_CUST_PAL ){ + pal[i][0] = vdi_web_pal[i-OFFSET_WEB_PAL][0]; + pal[i][1] = vdi_web_pal[i-OFFSET_WEB_PAL][1]; + pal[i][2] = vdi_web_pal[i-OFFSET_WEB_PAL][2]; + //set the new palette color to websafe value: + vs_color(atari_plot_vdi_handle, i, &pal[i][0]); + } + if( i >= OFFSET_CUST_PAL && i<OFFSET_CUST_PAL+16 ) { + /* here we define 20 additional gray colors... */ + rgbcol[1] = rgbcol[2] = rgbcol[3] = ((graytone&0x0F) << 4); + rgb_to_vdi1000( &rgbcol[0], &pal[i][0] ); + vs_color(atari_plot_vdi_handle, i, &pal[i][0]); + graytone++; + } + + } + vdi1000_to_rgb( &pal[i][0], &rgb_lookup[i][0] ); + } } else { - /* no need to change the palette - its application specific */ + /* no need to change the palette - its application specific */ } #else bitmap_convert = bitmap_convert_tc; @@ -1675,6 +1744,7 @@ int plot_init(char * fdrvrname) return( err ); } + int plot_finalise( void ) { @@ -1682,10 +1752,10 @@ int plot_finalise( void ) #ifdef WITH_8BPP_SUPPORT if (vfmt.indexed) { - int i; - for (i=OFFSET_WEB_PAL; i<OFFSET_CUST_PAL+16; i++) { - vs_color(atari_plot_vdi_handle, i, &sys_pal[i][0]); - } + int i; + for (i=OFFSET_WEB_PAL; i<OFFSET_CUST_PAL+16; i++) { + vs_color(atari_plot_vdi_handle, i, &sys_pal[i][0]); + } } #endif @@ -1701,25 +1771,27 @@ int plot_finalise( void ) return 0; } + bool plot_lock(void) { if ((atari_plot_flags & PLOT_FLAG_LOCKED) != 0) - return(true); + return(true); if( !wind_update(BEG_UPDATE|0x100) ) - return(false); + return(false); if( !wind_update(BEG_MCTRL|0x100) ){ - wind_update(END_UPDATE); - return(false); + wind_update(END_UPDATE); + return(false); } atari_plot_flags |= PLOT_FLAG_LOCKED; graf_mouse(M_OFF, NULL); return(true); } + bool plot_unlock(void) { if( (atari_plot_flags & PLOT_FLAG_LOCKED) == 0 ) - return(true); + return(true); wind_update(END_MCTRL); wind_update(END_UPDATE); graf_mouse(M_ON, NULL); @@ -1728,214 +1800,40 @@ bool plot_unlock(void) return(false); } -bool plot_rectangle(int x0, int y0, int x1, int y1, - const plot_style_t *pstyle ) -{ - short pxy[4]; - GRECT r, rclip, sclip; - int sw = pstyle->stroke_width; - uint32_t lt; - - /* current canvas clip: */ - rclip.g_x = view.clipping.x0; - rclip.g_y = view.clipping.y0; - rclip.g_w = view.clipping.x1 - view.clipping.x0; - rclip.g_h = view.clipping.y1 - view.clipping.y0; - - /* physical clipping: */ - sclip.g_x = rclip.g_x; - sclip.g_y = rclip.g_y; - sclip.g_w = view.vis_w; - sclip.g_h = view.vis_h; - rc_intersect(&sclip, &rclip); - r.g_x = x0; - r.g_y = y0; - r.g_w = x1 - x0; - r.g_h = y1 - y0; - - if (!rc_intersect( &rclip, &r )) { - return(true); - } - if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) { - /* - manually draw the line, because we do not need vdi clipping - for vertical / horizontal line draws. - */ - if( sw == 0) - sw = 1; - - NSLT2VDI(lt, pstyle); - vsl_type(atari_plot_vdi_handle, (lt&0x0F)); - /* - if the line style is not available within VDI system, - define own style: - */ - if( (lt&0x0F) == 7 ){ - vsl_udsty(atari_plot_vdi_handle, ((lt&0xFFFF00) >> 8)); - } - vsl_width(atari_plot_vdi_handle, (short)sw ); - vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); - /* top border: */ - if( r.g_y == y0){ - pxy[0] = view.x + r.g_x; - pxy[1] = view.y + r.g_y ; - pxy[2] = view.x + r.g_x + r.g_w; - pxy[3] = view.y + r.g_y; - v_pline(atari_plot_vdi_handle, 2, (short *)&pxy); - } - - /* right border: */ - if( r.g_x + r.g_w == x1 ){ - pxy[0] = view.x + r.g_x + r.g_w; - pxy[1] = view.y + r.g_y; - pxy[2] = view.x + r.g_x + r.g_w; - pxy[3] = view.y + r.g_y + r.g_h; - v_pline(atari_plot_vdi_handle, 2, (short *)&pxy); - } - - /* bottom border: */ - if( r.g_y+r.g_h == y1 ){ - pxy[0] = view.x + r.g_x; - pxy[1] = view.y + r.g_y+r.g_h; - pxy[2] = view.x + r.g_x+r.g_w; - pxy[3] = view.y + r.g_y+r.g_h; - v_pline(atari_plot_vdi_handle, 2, (short *)&pxy); - } - - /* left border: */ - if( r.g_x == x0 ){ - pxy[0] = view.x + r.g_x; - pxy[1] = view.y + r.g_y; - pxy[2] = view.x + r.g_x; - pxy[3] = view.y + r.g_y + r.g_h; - v_pline(atari_plot_vdi_handle, 2, (short *)&pxy); - } - } - - if( pstyle->fill_type != PLOT_OP_TYPE_NONE ){ - short stroke_width = (short)(pstyle->stroke_type != PLOT_OP_TYPE_NONE) ? - pstyle->stroke_width : 0; - - vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour); - vsf_perimeter(atari_plot_vdi_handle, 0); - vsf_interior(atari_plot_vdi_handle, FIS_SOLID); - - - pxy[0] = view.x + r.g_x + stroke_width; - pxy[1] = view.y + r.g_y + stroke_width; - pxy[2] = view.x + r.g_x + r.g_w -1 - stroke_width; - pxy[3] = view.y + r.g_y + r.g_h -1 - stroke_width; - - vsf_style(atari_plot_vdi_handle, 1); - v_bar(atari_plot_vdi_handle, (short*)&pxy); - } - return (true); -} - -bool plot_line(int x0, int y0, int x1, int y1, - const plot_style_t *pstyle ) -{ - short pxy[4]; - uint32_t lt; - int sw = pstyle->stroke_width; - - if((x0 < 0 && x1 < 0) || (y0 < 0 && y1 < 0)){ - return(true); - } - - pxy[0] = view.x + MAX(0,x0); - pxy[1] = view.y + MAX(0,y0); - pxy[2] = view.x + MAX(0,x1); - pxy[3] = view.y + MAX(0,y1); - - if((y0 > view.h-1) && (y1 > view.h-1)) - return(true); - - //printf("view: %d,%d,%d,%d\n", view.x, view.y, view.w, view.h); - //printf("line: %d,%d,%d,%d\n", x0, y0, x1, y1); - - - //plot_vdi_clip(true); - if( sw == 0) - sw = 1; - NSLT2VDI(lt, pstyle) - vsl_type(atari_plot_vdi_handle, (lt&0x0F)); - /* if the line style is not available within VDI system,define own style: */ - if( (lt&0x0F) == 7 ){ - vsl_udsty(atari_plot_vdi_handle, ((lt&0xFFFF00) >> 8)); - } - vsl_width(atari_plot_vdi_handle, (short)sw); - vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); - v_pline(atari_plot_vdi_handle, 2, (short *)&pxy ); - //plot_vdi_clip(false); - return (true); -} - -static bool plot_polygon(const int *p, unsigned int n, - const plot_style_t *pstyle) -{ - short pxy[n*2]; - unsigned int i=0; - if (vdi_sysinfo.maxpolycoords > 0) - assert( (signed int)n < vdi_sysinfo.maxpolycoords); - - vsf_interior(atari_plot_vdi_handle, FIS_SOLID); - vsf_style(atari_plot_vdi_handle, 1); - for (i = 0; i<n*2; i=i+2) { - pxy[i] = (short)view.x+p[i]; - pxy[i+1] = (short)view.y+p[i+1]; - } - if (pstyle->fill_type == PLOT_OP_TYPE_SOLID) { - vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour); - v_fillarea(atari_plot_vdi_handle, n, (short*)&pxy); - } else { - pxy[n*2]=pxy[0]; - pxy[n*2+1]=pxy[1]; - vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); - v_pline(atari_plot_vdi_handle, n+1, (short *)&pxy); - } - - return ( true ); -} - -/*** - * Set plot origin and canvas size - * \param x the x origin - * \param y the y origin - * \param w the width of the plot area - * \param h the height of the plot area - */ -bool plot_set_dimensions(int x, int y, int w, int h) +/* exported interface documented in atari/plot.h */ +bool +plot_set_dimensions(const struct redraw_context *ctx, int x, int y, int w, int h) { bool doupdate = false; struct rect newclip = {0, 0, w, h}; GRECT absclip = {x, y, w, h}; if (!(w == view.w && h == view.h)) { - view.w = (short)w; - view.h = (short)h; - doupdate = true; + view.w = (short)w; + view.h = (short)h; + doupdate = true; } if (!(x == view.x && y == view.y)) { - view.x = (short)x; - view.y = (short)y; - doupdate = true; + view.x = (short)x; + view.y = (short)y; + doupdate = true; } if (doupdate==true) - update_visible_rect(); + update_visible_rect(); //dbg_rect("plot_set_dimensions", &newclip); plot_set_abs_clipping(&absclip); - plot_clip(&newclip); + ctx->plot->clip(ctx, &newclip); return(true); } -/*** + +/** * Get current canvas size - * \param dst the GRECT * which receives the canvas size * + * \param dst the GRECT * which receives the canvas size */ bool plot_get_dimensions(GRECT *dst) { @@ -1946,6 +1844,7 @@ bool plot_get_dimensions(GRECT *dst) return(true); } + /** * set scale of plotter. * \param scale the new scale value @@ -1961,6 +1860,7 @@ float plot_set_scale(float scale) return(ret); } + float plot_get_scale(void) { return(view.scale); @@ -1968,10 +1868,9 @@ float plot_get_scale(void) /** - * * Subsequent calls to plot_clip will be clipped by the absolute clip. - * \param area the maximum clipping rectangle (absolute screen coords) * + * \param area the maximum clipping rectangle (absolute screen coords) */ void plot_set_abs_clipping(const GRECT *area) { @@ -1980,21 +1879,20 @@ void plot_set_abs_clipping(const GRECT *area) plot_get_dimensions(&canvas); if(!rc_intersect(area, &canvas)){ - view.abs_clipping.x0 = 0; - view.abs_clipping.x1 = 0; - view.abs_clipping.y0 = 0; - view.abs_clipping.y1 = 0; - } - else { - view.abs_clipping.x0 = area->g_x; - view.abs_clipping.x1 = area->g_x + area->g_w; - view.abs_clipping.y0 = area->g_y; - view.abs_clipping.y1 = area->g_y + area->g_h; + view.abs_clipping.x0 = 0; + view.abs_clipping.x1 = 0; + view.abs_clipping.y0 = 0; + view.abs_clipping.y1 = 0; + } else { + view.abs_clipping.x0 = area->g_x; + view.abs_clipping.x1 = area->g_x + area->g_w; + view.abs_clipping.y0 = area->g_y; + view.abs_clipping.y1 = area->g_y + area->g_h; } } -/*** +/** * Get the maximum clip extent, in absolute screen coords * \param dst the structure that receives the absolute clipping */ @@ -2004,7 +1902,7 @@ void plot_get_abs_clipping(struct rect *dst) } -/*** +/** * Get the maximum clip extent, in absolute screen coords * \param dst the structure that receives the absolute clipping */ @@ -2016,7 +1914,64 @@ void plot_get_abs_clipping_grect(GRECT *dst) dst->g_h = view.abs_clipping.y1 - view.abs_clipping.y0; } -bool plot_clip(const struct rect *clip) + +VdiHdl plot_get_vdi_handle(void) +{ + return(atari_plot_vdi_handle); +} + + +long plot_get_flags(void) +{ + return(atari_plot_flags); +} + + +bool plot_get_clip(struct rect * out) +{ + out->x0 = view.clipping.x0; + out->y0 = view.clipping.y0; + out->x1 = view.clipping.x1; + out->y1 = view.clipping.y1; + return( true ); +} + + +void plot_get_clip_grect(GRECT * out) +{ + struct rect clip={0,0,0,0}; + + plot_get_clip(&clip); + + out->g_x = clip.x0; + out->g_y = clip.y0; + out->g_w = clip.x1 - clip.x0; + out->g_h = clip.y1 - clip.y0; +} + + +FONT_PLOTTER plot_get_text_plotter() +{ + return(fplotter); +} + + +void plot_set_text_plotter(FONT_PLOTTER font_plotter) +{ + fplotter = font_plotter; +} + + +/** + * \brief Sets a clip rectangle for subsequent plot operations. + * + * \param ctx The current redraw context. + * \param clip The rectangle to limit all subsequent plot + * operations within. + * \return NSERROR_OK on success else error code. + */ +static nserror +plot_clip(const struct redraw_context *ctx, const struct rect *clip) { GRECT canvas, screen, gclip, maxclip; short pxy[4]; @@ -2041,14 +1996,14 @@ bool plot_clip(const struct rect *clip) rc_intersect(&canvas, &gclip); if(gclip.g_h < 0){ - gclip.g_h = 0; + gclip.g_h = 0; } if (!rc_intersect(&screen, &gclip)) { - //dbg_rect("cliprect: ", &view.clipping); - //dbg_grect("screen: ", &canvas); - //dbg_grect("canvas clipped: ", &gclip); - //assert(1 == 0); + //dbg_rect("cliprect: ", &view.clipping); + //dbg_grect("screen: ", &canvas); + //dbg_grect("canvas clipped: ", &gclip); + //assert(1 == 0); } // When setting VDI clipping, obey to maximum cliping rectangle: @@ -2064,106 +2019,377 @@ bool plot_clip(const struct rect *clip) vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy); - return ( true ); + return NSERROR_OK; } -VdiHdl plot_get_vdi_handle(void) -{ - return(atari_plot_vdi_handle); -} -long plot_get_flags(void) +/** + * Plots an arc + * + * plot an arc segment around (x,y), anticlockwise from angle1 + * to angle2. Angles are measured anticlockwise from + * horizontal, in degrees. + * + * \param ctx The current redraw context. + * \param pstyle Style controlling the arc plot. + * \param x The x coordinate of the arc. + * \param y The y coordinate of the arc. + * \param radius The radius of the arc. + * \param angle1 The start angle of the arc. + * \param angle2 The finish angle of the arc. + * \return NSERROR_OK on success else error code. + */ +static nserror +plot_arc(const struct redraw_context *ctx, + const plot_style_t *pstyle, + int x, int y, int radius, int angle1, int angle2) { - return(atari_plot_flags); + vswr_mode(atari_plot_vdi_handle, MD_REPLACE); + if (pstyle->fill_type == PLOT_OP_TYPE_NONE) { + return NSERROR_OK; + } + + if (pstyle->fill_type != PLOT_OP_TYPE_SOLID) { + vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); + vsf_perimeter(atari_plot_vdi_handle, 1); + vsf_interior(atari_plot_vdi_handle, 1 ); + v_arc(atari_plot_vdi_handle, + view.x + x, + view.y + y, + radius, + angle1 * 10, + angle2 * 10); + } else { + vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour); + vsl_width(atari_plot_vdi_handle, 1); + vsf_perimeter(atari_plot_vdi_handle, 1); + v_arc(atari_plot_vdi_handle, + view.x + x, + view.y + y, radius, + angle1 * 10, + angle2 * 10); + } + + return NSERROR_OK; } -bool plot_get_clip(struct rect * out) +/** + * Plots a circle + * + * Plot a circle centered on (x,y), which is optionally filled. + * + * \param ctx The current redraw context. + * \param pstyle Style controlling the circle plot. + * \param x x coordinate of circle centre. + * \param y y coordinate of circle centre. + * \param radius circle radius. + * \return NSERROR_OK on success else error code. + */ +static nserror +plot_disc(const struct redraw_context *ctx, + const plot_style_t *pstyle, + int x, int y, int radius) { - out->x0 = view.clipping.x0; - out->y0 = view.clipping.y0; - out->x1 = view.clipping.x1; - out->y1 = view.clipping.y1; - return( true ); + if (pstyle->fill_type != PLOT_OP_TYPE_SOLID) { + vsf_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); + vsf_perimeter(atari_plot_vdi_handle, 1); + vsf_interior(atari_plot_vdi_handle, 0); + v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius); + } else { + vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour); + vsf_perimeter(atari_plot_vdi_handle, 0); + vsf_interior(atari_plot_vdi_handle, FIS_SOLID); + v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius); + } + return NSERROR_OK; } -void plot_get_clip_grect(GRECT * out) + +/** + * Plots a line + * + * plot a line from (x0,y0) to (x1,y1). Coordinates are at + * centre of line width/thickness. + * + * \param ctx The current redraw context. + * \param pstyle Style controlling the line plot. + * \param line A rectangle defining the line to be drawn + * \return NSERROR_OK on success else error code. + */ +static nserror +plot_line(const struct redraw_context *ctx, + const plot_style_t *pstyle, + const struct rect *line) { - struct rect clip={0,0,0,0}; + short pxy[4]; + uint32_t lt; + int sw = plot_style_fixed_to_int(pstyle->stroke_width); - plot_get_clip(&clip); + if (((line->x0 < 0) && (line->x1 < 0)) || + ((line->y0 < 0) && (line->y1 < 0))) { + return NSERROR_OK; + } - out->g_x = clip.x0; - out->g_y = clip.y0; - out->g_w = clip.x1 - clip.x0; - out->g_h = clip.y1 - clip.y0; -} + pxy[0] = view.x + MAX(0, line->x0); + pxy[1] = view.y + MAX(0, line->y0); + pxy[2] = view.x + MAX(0, line->x1); + pxy[3] = view.y + MAX(0, line->y1); -FONT_PLOTTER plot_get_text_plotter() -{ - return(fplotter); -} + if ((line->y0 > view.h-1) && (line->y1 > view.h-1)) { + return NSERROR_OK; + } -void plot_set_text_plotter(FONT_PLOTTER font_plotter) -{ - fplotter = font_plotter; -} + //printf("view: %d,%d,%d,%d\n", view.x, view.y, view.w, view.h); + //printf("line: %d,%d,%d,%d\n", x0, y0, x1, y1); -static bool plot_text(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle ) -{ - if (view.scale != 1.0) { - plot_font_style_t newstyle = *fstyle; - newstyle.size = (int)((float)fstyle->size*view.scale); - fplotter->text(fplotter, x, y, text, length, &newstyle); - } else { - fplotter->text(fplotter, x, y, text, length, fstyle); + //plot_vdi_clip(true); + + if (sw == 0) { + sw = 1; } + NSLT2VDI(lt, pstyle) + vsl_type(atari_plot_vdi_handle, (lt&0x0F)); + /* if the line style is not available within VDI system,define own style: */ + if ((lt&0x0F) == 7 ) { + vsl_udsty(atari_plot_vdi_handle, ((lt&0xFFFF00) >> 8)); + } + vsl_width(atari_plot_vdi_handle, (short)sw); + vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); + v_pline(atari_plot_vdi_handle, 2, (short *)&pxy ); + //plot_vdi_clip(false); - return ( true ); + return NSERROR_OK; } -static bool plot_disc(int x, int y, int radius, const plot_style_t *pstyle) + +/** + * Plots a rectangle. + * + * The rectangle can be filled an outline or both controlled + * by the plot style The line can be solid, dotted or + * dashed. Top left corner at (x0,y0) and rectangle has given + * width and height. + * + * \param ctx The current redraw context. + * \param pstyle Style controlling the rectangle plot. + * \param rect A rectangle defining the line to be drawn + * \return NSERROR_OK on success else error code. + */ +static nserror +plot_rectangle(const struct redraw_context *ctx, + const plot_style_t *pstyle, + const struct rect *rect) { - if (pstyle->fill_type != PLOT_OP_TYPE_SOLID) { - vsf_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); - vsf_perimeter(atari_plot_vdi_handle, 1); - vsf_interior(atari_plot_vdi_handle, 0); - v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius); - } else { - vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour); - vsf_perimeter(atari_plot_vdi_handle, 0); - vsf_interior(atari_plot_vdi_handle, FIS_SOLID); - v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius); + short pxy[4]; + GRECT r, rclip, sclip; + int sw = plot_style_fixed_to_int(pstyle->stroke_width); + uint32_t lt; + + /* current canvas clip: */ + rclip.g_x = view.clipping.x0; + rclip.g_y = view.clipping.y0; + rclip.g_w = view.clipping.x1 - view.clipping.x0; + rclip.g_h = view.clipping.y1 - view.clipping.y0; + + /* physical clipping: */ + sclip.g_x = rclip.g_x; + sclip.g_y = rclip.g_y; + sclip.g_w = view.vis_w; + sclip.g_h = view.vis_h; + + rc_intersect(&sclip, &rclip); + r.g_x = rect->x0; + r.g_y = rect->y0; + r.g_w = rect->x1 - rect->x0; + r.g_h = rect->y1 - rect->y0; + + if (!rc_intersect(&rclip, &r)) { + return NSERROR_OK; } - return(true); + if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) { + /* + manually draw the line, because we do not need vdi clipping + for vertical / horizontal line draws. + */ + if (sw == 0) + sw = 1; + + NSLT2VDI(lt, pstyle); + vsl_type(atari_plot_vdi_handle, (lt&0x0F)); + /* + if the line style is not available within VDI system, + define own style: + */ + if ((lt&0x0F) == 7 ) { + vsl_udsty(atari_plot_vdi_handle, ((lt&0xFFFF00) >> 8)); + } + vsl_width(atari_plot_vdi_handle, (short)sw ); + vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); + /* top border: */ + if (r.g_y == rect->y0) { + pxy[0] = view.x + r.g_x; + pxy[1] = view.y + r.g_y ; + pxy[2] = view.x + r.g_x + r.g_w; + pxy[3] = view.y + r.g_y; + v_pline(atari_plot_vdi_handle, 2, (short *)&pxy); + } + + /* right border: */ + if (r.g_x + r.g_w == rect->x1 ) { + pxy[0] = view.x + r.g_x + r.g_w; + pxy[1] = view.y + r.g_y; + pxy[2] = view.x + r.g_x + r.g_w; + pxy[3] = view.y + r.g_y + r.g_h; + v_pline(atari_plot_vdi_handle, 2, (short *)&pxy); + } + + /* bottom border: */ + if ( r.g_y+r.g_h == rect->y1 ) { + pxy[0] = view.x + r.g_x; + pxy[1] = view.y + r.g_y+r.g_h; + pxy[2] = view.x + r.g_x+r.g_w; + pxy[3] = view.y + r.g_y+r.g_h; + v_pline(atari_plot_vdi_handle, 2, (short *)&pxy); + } + + /* left border: */ + if ( r.g_x == rect->x0 ) { + pxy[0] = view.x + r.g_x; + pxy[1] = view.y + r.g_y; + pxy[2] = view.x + r.g_x; + pxy[3] = view.y + r.g_y + r.g_h; + v_pline(atari_plot_vdi_handle, 2, (short *)&pxy); + } + } + + if (pstyle->fill_type != PLOT_OP_TYPE_NONE ) { + short stroke_width = (short)(pstyle->stroke_type != PLOT_OP_TYPE_NONE) ? + plot_style_fixed_to_int(pstyle->stroke_width) : 0; + + vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour); + vsf_perimeter(atari_plot_vdi_handle, 0); + vsf_interior(atari_plot_vdi_handle, FIS_SOLID); + + + pxy[0] = view.x + r.g_x + stroke_width; + pxy[1] = view.y + r.g_y + stroke_width; + pxy[2] = view.x + r.g_x + r.g_w -1 - stroke_width; + pxy[3] = view.y + r.g_y + r.g_h -1 - stroke_width; + + vsf_style(atari_plot_vdi_handle, 1); + v_bar(atari_plot_vdi_handle, (short*)&pxy); + } + + return NSERROR_OK; } -static bool plot_arc(int x, int y, int radius, int angle1, int angle2, - const plot_style_t *pstyle) + +/** + * Plot a polygon + * + * Plots a filled polygon with straight lines between + * points. The lines around the edge of the ploygon are not + * plotted. The polygon is filled with the non-zero winding + * rule. + * + * \param ctx The current redraw context. + * \param pstyle Style controlling the polygon plot. + * \param p verticies of polygon + * \param n number of verticies. + * \return NSERROR_OK on success else error code. + */ +static nserror +plot_polygon(const struct redraw_context *ctx, + const plot_style_t *pstyle, + const int *p, + unsigned int n) { + short pxy[n*2]; + unsigned int i = 0; - vswr_mode(atari_plot_vdi_handle, MD_REPLACE ); - if (pstyle->fill_type == PLOT_OP_TYPE_NONE) - return(true); - if ( pstyle->fill_type != PLOT_OP_TYPE_SOLID) { - vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); - vsf_perimeter(atari_plot_vdi_handle, 1); - vsf_interior(atari_plot_vdi_handle, 1 ); - v_arc(atari_plot_vdi_handle, view.x + x, view.y + y, radius, angle1*10, angle2*10); + if (vdi_sysinfo.maxpolycoords > 0) + assert( (signed int)n < vdi_sysinfo.maxpolycoords); + + vsf_interior(atari_plot_vdi_handle, FIS_SOLID); + vsf_style(atari_plot_vdi_handle, 1); + for (i = 0; i<n*2; i=i+2) { + pxy[i] = (short)view.x+p[i]; + pxy[i+1] = (short)view.y+p[i+1]; + } + + if (pstyle->fill_type == PLOT_OP_TYPE_SOLID) { + vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour); + v_fillarea(atari_plot_vdi_handle, n, (short*)&pxy); } else { - vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour); - vsl_width(atari_plot_vdi_handle, 1 ); - vsf_perimeter(atari_plot_vdi_handle, 1); - v_arc(atari_plot_vdi_handle, view.x + x, view.y + y, radius, angle1*10, angle2*10); + pxy[n*2]=pxy[0]; + pxy[n*2+1]=pxy[1]; + vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour); + v_pline(atari_plot_vdi_handle, n+1, (short *)&pxy); } - return (true); + return NSERROR_OK; } -static bool plot_bitmap(int x, int y, int width, int height, - struct bitmap *bitmap, colour bg, - bitmap_flags_t flags) + +/** + * Plots a path. + * + * Path plot consisting of cubic Bezier curves. Line and fill colour is + * controlled by the plot style. + * + * \param ctx The current redraw context. + * \param pstyle Style controlling the path plot. + * \param p elements of path + * \param n nunber of elements on path + * \param transform A transform to apply to the path. + * \return NSERROR_OK on success else error code. + */ +static nserror +plot_path(const struct redraw_context *ctx, + const plot_style_t *pstyle, + const float *p, + unsigned int n, + const float transform[6]) +{ + /** \todo Implement atari path plot */ + return NSERROR_OK; +} + + +/** + * Plot a bitmap + * + * Tiled plot of a bitmap image. (x,y) gives the top left + * coordinate of an explicitly placed tile. From this tile the + * image can repeat in all four directions -- up, down, left + * and right -- to the extents given by the current clip + * rectangle. + * + * The bitmap_flags say whether to tile in the x and y + * directions. If not tiling in x or y directions, the single + * image is plotted. The width and height give the dimensions + * the image is to be scaled to. + * + * \param ctx The current redraw context. + * \param bitmap The bitmap to plot + * \param x The x coordinate to plot the bitmap + * \param y The y coordiante to plot the bitmap + * \param width The width of area to plot the bitmap into + * \param height The height of area to plot the bitmap into + * \param bg the background colour to alpha blend into + * \param flags the flags controlling the type of plot operation + * \return NSERROR_OK on success else error code. + */ +static nserror +plot_bitmap(const struct redraw_context *ctx, + struct bitmap *bitmap, + int x, int y, + int width, + int height, + colour bg, + bitmap_flags_t flags) { struct bitmap * bm = NULL; bool repeat_x = (flags & BITMAPF_REPEAT_X); @@ -2175,78 +2401,109 @@ static bool plot_bitmap(int x, int y, int width, int height, bmph = atari_bitmap_get_height(bitmap); if(view.scale != 1.0){ - width = (int)(((float)width)*view.scale); - height = (int)(((float)height)*view.scale); + width = (int)(((float)width)*view.scale); + height = (int)(((float)height)*view.scale); } if ( repeat_x || repeat_y ) { - plot_get_clip(&clip); - if( repeat_x && width == 1 && repeat_y && height == 1 ) { - width = MAX( width, clip.x1 - x ); - height = MAX( height, clip.y1 - y ); - } else if( repeat_x && width == 1 ) { - width = MAX( width, clip.x1 - x); - } else if( repeat_y && height == 1) { - height = MAX( height, clip.y1 - y ); - } - } - - if( width != bmpw || height != bmph ) { - atari_bitmap_resize(bitmap, hermes_res_h, &nsfmt, width, height ); - if( bitmap->resized ) - bm = bitmap->resized; - else - bm = bitmap; + plot_get_clip(&clip); + if (repeat_x && width == 1 && repeat_y && height == 1 ) { + width = MAX( width, clip.x1 - x ); + height = MAX( height, clip.y1 - y ); + } else if (repeat_x && width == 1 ) { + width = MAX( width, clip.x1 - x); + } else if (repeat_y && height == 1) { + height = MAX( height, clip.y1 - y ); + } + } + + if (width != bmpw || height != bmph) { + atari_bitmap_resize(bitmap, hermes_res_h, &nsfmt, width, height ); + if (bitmap->resized) { + bm = bitmap->resized; + } else { + bm = bitmap; + } } else { - bm = bitmap; + bm = bitmap; } /* out of memory? */ - if( bm == NULL ) { - printf("plot: out of memory! bmp: %p, bmpres: %p\n", bitmap, bitmap->resized ); - return( true ); + if (bm == NULL) { + printf("plot: out of memory! bmp: %p, bmpres: %p\n", + bitmap, bitmap->resized ); + return NSERROR_NOMEM; } if (!(repeat_x || repeat_y) ) { - plot_blit_bitmap(bm, x, y, bg, flags ); + plot_blit_bitmap(bm, x, y, bg, flags); } else { - int xf,yf; - int xoff = x; - int yoff = y; - - if (yoff > clip.y0 ) - yoff = (clip.y0 - height) + ((yoff - clip.y0) % height); - if (xoff > clip.x0 ) - xoff = (clip.x0 - width) + ((xoff - clip.x0) % width); - /* for now, repeating just works in the rigth / down direction */ - /* - if( repeat_x == true ) - xoff = clip.x0; - if(repeat_y == true ) - yoff = clip.y0; - */ - - for( xf = xoff; xf < clip.x1; xf += width ) { - for( yf = yoff; yf < clip.y1; yf += height ) { - plot_blit_bitmap(bm, xf, yf, bg, flags ); - if (!repeat_y) - break; - } - if (!repeat_x) - break; - } - } - return ( true ); + int xf,yf; + int xoff = x; + int yoff = y; + + if (yoff > clip.y0) { + yoff = (clip.y0 - height) + ((yoff - clip.y0) % height); + } + if (xoff > clip.x0) { + xoff = (clip.x0 - width) + ((xoff - clip.x0) % width); + } + /* for now, repeating just works in the rigth / down direction */ + /* + if( repeat_x == true ) + xoff = clip.x0; + if(repeat_y == true ) + yoff = clip.y0; + */ + + for (xf = xoff; xf < clip.x1; xf += width ) { + for (yf = yoff; yf < clip.y1; yf += height ) { + plot_blit_bitmap(bm, xf, yf, bg, flags ); + if (!repeat_y) { + break; + } + } + if (!repeat_x) { + break; + } + } + } + + return NSERROR_OK; } -static bool plot_path(const float *p, unsigned int n, colour fill, float width, - colour c, const float transform[6]) -{ - return ( true ); -} +/** + * Text plotting. + * + * \param ctx The current redraw context. + * \param fstyle plot style for this text + * \param x x coordinate + * \param y y coordinate + * \param text UTF-8 string to plot + * \param length length of string, in bytes + * \return NSERROR_OK on success else error code. + */ +static nserror +plot_text(const struct redraw_context *ctx, + const struct plot_font_style *fstyle, + int x, + int y, + const char *text, + size_t length) +{ + if (view.scale != 1.0) { + plot_font_style_t newstyle = *fstyle; + newstyle.size = (int)((float)fstyle->size*view.scale); + fplotter->text(fplotter, x, y, text, length, &newstyle); + } else { + fplotter->text(fplotter, x, y, text, length, fstyle); + } + return NSERROR_OK; +} +/** atari plottr operation table */ const struct plotter_table atari_plotters = { .rectangle = plot_rectangle, .line = plot_line, diff --git a/frontends/atari/plot/plot.h b/frontends/atari/plot/plot.h index fd73a8c33..a827c008c 100644 --- a/frontends/atari/plot/plot.h +++ b/frontends/atari/plot/plot.h @@ -55,6 +55,7 @@ #define ERR_PLOTTER_NOT_AVAILABLE 3 /* invalid plotter driver name passed */ struct plot_style_s; +struct redraw_context; struct s_vdi_sysinfo { short vdi_handle; /**< vdi handle */ @@ -83,7 +84,16 @@ struct rect; extern const struct plotter_table atari_plotters; -int plot_init(char *); +/** + * Init screen and font driver objects. + * + * \param ctx The current redraw context. + * \param fdrvrname font driver name. + * \return value > 1 when the objects could be succesfully created or + * <= 0 to indicate an error. + */ +int plot_init(const struct redraw_context *ctx, char *fdrvrname); + int plot_finalise(void); /** @@ -93,7 +103,17 @@ const char* plot_err_str(int i) ; bool plot_lock(void); bool plot_unlock(void); -bool plot_set_dimensions( int x, int y, int w, int h ); + +/** + * Set plot origin and canvas size + * + * \param ctx The current redraw context. + * \param x the x origin + * \param y the y origin + * \param w the width of the plot area + * \param h the height of the plot area + */ +bool plot_set_dimensions(const struct redraw_context *ctx, int x, int y, int w, int h ); bool plot_get_dimensions(GRECT *dst); float plot_get_scale(void); float plot_set_scale(float); @@ -101,13 +121,10 @@ void plot_set_abs_clipping(const GRECT *area); void plot_get_abs_clipping(struct rect *dst); void plot_get_abs_clipping_grect(GRECT *dst); bool plot_get_clip(struct rect * out); -/* Get clipping for current framebuffer as GRECT */ +/** Get clipping for current framebuffer as GRECT */ void plot_get_clip_grect(GRECT * out); -bool plot_clip(const struct rect *clip); VdiHdl plot_get_vdi_handle(void); long plot_get_flags(void); -bool plot_rectangle( int x0, int y0, int x1, int y1,const struct plot_style_s *style ); -bool plot_line( int x0, int y0, int x1, int y1, const struct plot_style_s *style ); bool plot_blit_bitmap(struct bitmap * bmp, int x, int y, unsigned long bg, unsigned long flags); bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor, uint32_t flags); diff --git a/frontends/atari/rootwin.c b/frontends/atari/rootwin.c index aa8e08047..6576eac77 100644 --- a/frontends/atari/rootwin.c +++ b/frontends/atari/rootwin.c @@ -105,7 +105,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) switch (msg[0]) { case WM_REDRAW: - LOG("WM_REDRAW"); + NSLOG(netsurf, INFO, "WM_REDRAW"); on_redraw(data->rootwin, msg); break; @@ -113,7 +113,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) case WM_SIZED: case WM_MOVED: case WM_FULLED: - LOG("WM_SIZED"); + NSLOG(netsurf, INFO, "WM_SIZED"); on_resized(data->rootwin); break; @@ -132,7 +132,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) case WM_TOPPED: case WM_NEWTOP: case WM_UNICONIFY: - LOG("WM_TOPPED"); + NSLOG(netsurf, INFO, "WM_TOPPED"); gui_set_input_gui_window(data->rootwin->active_gui_window); //window_restore_active_gui_window(data->rootwin); // TODO: use something like "restore_active_gui_window_state()" @@ -143,7 +143,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) // TODO: this needs to iterate through all gui windows and // check if the rootwin is this window... if (data->rootwin->active_gui_window != NULL) { - LOG("WM_CLOSED initiated destroy for bw %p", data->rootwin->active_gui_window->browser->bw); + NSLOG(netsurf, INFO, "WM_CLOSED initiated destroy for bw %p", + data->rootwin->active_gui_window->browser->bw); browser_window_destroy( data->rootwin->active_gui_window->browser->bw); } @@ -166,13 +167,16 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) // handle key uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta, (short)ev_out->emo_kreturn); - LOG("rootwin MU_KEYBD input, nkc: %x\n", nkc); + NSLOG(netsurf, INFO, "rootwin MU_KEYBD input, nkc: %x\n", nkc); retval = on_window_key_input(data->rootwin, nkc); // printf("on_window_key_input: %d\n", retval); } if ((ev_out->emo_events & MU_BUTTON) != 0) { - LOG("rootwin MU_BUTTON input, x: %d, y: %d\n", ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_x); + NSLOG(netsurf, INFO, + "rootwin MU_BUTTON input, x: %d, y: %d\n", + ev_out->emo_mouse.p_x, + ev_out->emo_mouse.p_x); window_get_grect(data->rootwin, BROWSER_AREA_CONTENT, &area); if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y, @@ -312,13 +316,13 @@ void window_unref_gui_window(ROOTWIN *rootwin, struct gui_window *gw) struct gui_window *w; input_window = NULL; - LOG("window: %p, gui_window: %p", rootwin, gw); + NSLOG(netsurf, INFO, "window: %p, gui_window: %p", rootwin, gw); w = window_list; // find the next active tab: while( w != NULL ) { if(w->root == rootwin && w != gw) { - LOG("activating next tab %p", w); + NSLOG(netsurf, INFO, "activating next tab %p", w); gui_set_input_gui_window(w); break; } @@ -338,7 +342,7 @@ int window_destroy(ROOTWIN *rootwin) assert(rootwin != NULL); - LOG("%p", rootwin); + NSLOG(netsurf, INFO, "%p", rootwin); if (gemtk_wm_get_user_data(rootwin->win) != NULL) { free(gemtk_wm_get_user_data(rootwin->win)); @@ -404,7 +408,7 @@ void window_restore_active_gui_window(ROOTWIN *rootwin) GRECT tb_area; struct gui_window *gw; - LOG("rootwin %p", rootwin); + NSLOG(netsurf, INFO, "rootwin %p", rootwin); assert(rootwin->active_gui_window); @@ -499,7 +503,7 @@ void window_set_focus(struct s_gui_win_root *rootwin, assert(rootwin != NULL); if (rootwin->focus.type != type || rootwin->focus.element != element) { - LOG("Set focus: %p (%d)\n", element, type); + NSLOG(netsurf, INFO, "Set focus: %p (%d)\n", element, type); rootwin->focus.type = type; rootwin->focus.element = element; switch( type ) { @@ -563,11 +567,11 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw) { struct gui_window *old_gw = rootwin->active_gui_window; - LOG("gw %p",gw); + NSLOG(netsurf, INFO, "gw %p", gw); if (rootwin->active_gui_window != NULL) { if(rootwin->active_gui_window == gw) { - LOG("nothing to do..."); + NSLOG(netsurf, INFO, "nothing to do..."); return; } } @@ -576,7 +580,7 @@ void window_set_active_gui_window(ROOTWIN *rootwin, struct gui_window *gw) rootwin->active_gui_window = gw; if (old_gw != NULL) { - LOG("restoring window..."); + NSLOG(netsurf, INFO, "restoring window..."); window_restore_active_gui_window(rootwin); } } @@ -651,7 +655,7 @@ void window_open_search(ROOTWIN *rootwin, bool reformat) GRECT area; OBJECT *obj; - LOG("rootwin %p", rootwin); + NSLOG(netsurf, INFO, "rootwin %p", rootwin); gw = rootwin->active_gui_window; bw = gw->browser->bw; @@ -758,8 +762,11 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip_ro) xoff = ((work.g_w-work.g_h)/2); work.g_w = work.g_h; } - plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, - work.g_h); + plot_set_dimensions(&rootwin_rdrw_ctx, + work.g_x+xoff, + work.g_y, + work.g_w, + work.g_h); wind_get_grect(rootwin->aes_handle, WF_FIRSTXYWH, &visible); while (visible.g_h > 0 && visible.g_w > 0) { @@ -776,8 +783,14 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip_ro) vs_clip(plot_vdi_handle, 1, (short*)&pxy); //dbg_pxy("vdi clip", (short*)&pxy); - atari_plotters.bitmap(0, 0, work.g_w, work.g_h, - rootwin->icon, 0xffffff, 0); + rootwin_rdrw_ctx.plot->bitmap(&rootwin_rdrw_ctx, + rootwin->icon, + 0, + 0, + work.g_w, + work.g_h, + 0xffffff, + 0); } else { //dbg_grect("redraw vis area outside", &visible); } @@ -822,7 +835,8 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area, //dbg_grect("browser redraw, content area", content_area); //dbg_grect("browser redraw, content clip", clip); - plot_set_dimensions(content_area->g_x, content_area->g_y, + plot_set_dimensions(&rootwin_rdrw_ctx, + content_area->g_x, content_area->g_y, content_area->g_w, content_area->g_h); oldscale = plot_set_scale(browser_window_get_scale(rootwin->active_gui_window->browser->bw)); @@ -849,7 +863,7 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area, redraw_area.x1 = content_area_rel.g_x + content_area_rel.g_w; redraw_area.y1 = content_area_rel.g_y + content_area_rel.g_h; - plot_clip(&redraw_area); + rootwin_rdrw_ctx.plot->clip(&rootwin_rdrw_ctx, &redraw_area); //dbg_rect("rdrw area", &redraw_area); @@ -1468,7 +1482,13 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8]) buff[size] = 0; - LOG("file: %s, ext: %s, size: %ld dropped at: %d,%d\n", (char *)buff, (char *)&ext, size, mx, my); + NSLOG(netsurf, INFO, + "file: %s, ext: %s, size: %ld dropped at: %d,%d\n", + (char *)buff, + (char *)&ext, + size, + mx, + my); gui_window_get_scroll(gw, &sx, &sy); @@ -1490,7 +1510,8 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8]) if (ret != NSERROR_OK) { free(buff); /* A bad encoding should never happen */ - LOG("utf8_from_local_encoding failed"); + NSLOG(netsurf, INFO, + "utf8_from_local_encoding failed"); assert(ret != NSERROR_BAD_ENCODING); /* no memory */ goto error; diff --git a/frontends/atari/schedule.c b/frontends/atari/schedule.c index 48980426d..9a7836b1f 100644 --- a/frontends/atari/schedule.c +++ b/frontends/atari/schedule.c @@ -23,15 +23,10 @@ #include "utils/sys_time.h" #include "utils/errors.h" +#include "utils/log.h" #include "atari/schedule.h" -#ifdef DEBUG_SCHEDULER -#include "utils/log.h" -#else -#define LOG(x...) -#endif - #define MS_NOW() ((clock() * 1000) / CLOCKS_PER_SEC) /* linked list of scheduled callbacks */ @@ -71,7 +66,7 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) return NSERROR_OK; } - LOG("removing %p, %p", callback, p); + NSLOG(schedule, DEBUG, "removing %p, %p", callback, p); cur_nscb = schedule_list; prev_nscb = NULL; @@ -80,7 +75,9 @@ static nserror schedule_remove(void (*callback)(void *p), void *p) if ((cur_nscb->callback == callback) && (cur_nscb->p == p)) { /* item to remove */ - LOG("callback entry %p removing %p(%p)", cur_nscb, cur_nscb->callback, cur_nscb->p); + NSLOG(schedule, DEBUG, + "callback entry %p removing %p(%p)", cur_nscb, + cur_nscb->callback, cur_nscb->p); /* remove callback */ unlnk_nscb = cur_nscb; @@ -118,7 +115,8 @@ nserror atari_schedule(int ival, void (*callback)(void *p), void *p) nscb->timeout = MS_NOW() + ival; - LOG("adding callback %p for %p(%p) at %d ms", nscb, callback, p, nscb->timeout); + NSLOG(schedule, DEBUG, "adding callback %p for %p(%p) at %d ms", nscb, + callback, p, nscb->timeout); nscb->callback = callback; nscb->p = p; @@ -164,7 +162,9 @@ int schedule_run(void) prev_nscb->next = unlnk_nscb->next; } - LOG("callback entry %p running %p(%p)", unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p); + NSLOG(schedule, DEBUG, + "callback entry %p running %p(%p)", unlnk_nscb, + unlnk_nscb->callback, unlnk_nscb->p); /* call callback */ unlnk_nscb->callback(unlnk_nscb->p); @@ -173,7 +173,7 @@ int schedule_run(void) /* need to deal with callback modifying the list. */ if (schedule_list == NULL) { - LOG("schedule_list == NULL"); + NSLOG(schedule, DEBUG, "schedule_list == NULL"); return -1; /* no more callbacks scheduled */ } @@ -198,7 +198,8 @@ int schedule_run(void) /* make rettime relative to now and convert to ms */ nexttime = nexttime - now; - LOG("returning time to next event as %ldms", nexttime); + NSLOG(schedule, DEBUG, "returning time to next event as %ldms", + nexttime); /*return next event time in milliseconds (24days max wait) */ return nexttime; @@ -210,14 +211,15 @@ void list_schedule(void) { struct nscallback *cur_nscb; - LOG("schedule list at ms clock %ld", MS_NOW()); + NSLOG(schedule, DEBUG, "schedule list at ms clock %ld", MS_NOW()); cur_nscb = schedule_list; while (cur_nscb != NULL) { - LOG("Schedule %p at %ld", cur_nscb, cur_nscb->timeout); + NSLOG(schedule, DEBUG, "Schedule %p at %ld", cur_nscb, + cur_nscb->timeout); cur_nscb = cur_nscb->next; } - LOG("Maxmium callbacks scheduled: %d", max_scheduled); + NSLOG(schedule, DEBUG, "Maxmium callbacks scheduled: %d", max_scheduled); } diff --git a/frontends/atari/search.c b/frontends/atari/search.c index 4da7f16a3..8df4ad676 100644 --- a/frontends/atari/search.c +++ b/frontends/atari/search.c @@ -67,7 +67,7 @@ struct gui_search_table *atari_search_table = &search_table; */ void nsatari_search_set_status(bool found, void *p) { - LOG("%p set status: %d\n", p, found); + NSLOG(netsurf, INFO, "%p set status: %d\n", p, found); // TODO: maybe update GUI } @@ -80,7 +80,7 @@ void nsatari_search_set_status(bool found, void *p) void nsatari_search_set_hourglass(bool active, void *p) { SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p; - LOG("active: %d, session: %p", active, p); + NSLOG(netsurf, INFO, "active: %d, session: %p", active, p); if (active) { gui_window_set_pointer(s->g, GUI_POINTER_PROGRESS); } else { @@ -99,7 +99,7 @@ void nsatari_search_set_hourglass(bool active, void *p) */ void nsatari_search_add_recent(const char *string, void *p) { - LOG("%p add recent: %s\n", p, string); + NSLOG(netsurf, INFO, "%p add recent: %s\n", p, string); } @@ -115,7 +115,7 @@ void nsatari_search_set_forward_state(bool active, void *p) GRECT area; SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p; /* deactivate back cb */ - LOG("%p: set forward state: %d\n", p, active); + NSLOG(netsurf, INFO, "%p: set forward state: %d\n", p, active); gw = s->g; @@ -142,7 +142,7 @@ void nsatari_search_set_back_state(bool active, void *p) GRECT area; SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p; /* deactivate back cb */ - LOG("%p: set back state: %d\n", p, active); + NSLOG(netsurf, INFO, "%p: set back state: %d\n", p, active); s->state.back_avail = active; gw = s->g; @@ -224,7 +224,7 @@ void nsatari_search_restore_form( struct s_search_form_session *s, OBJECT *obj) void nsatari_search_session_destroy(struct s_search_form_session *s) { if (s != NULL) { - LOG("session %p", s); + NSLOG(netsurf, INFO, "session %p", s); browser_window_search_clear(s->g->browser->bw); free(s); } diff --git a/frontends/atari/settings.c b/frontends/atari/settings.c index ed1fb2e45..7084bacf7 100644 --- a/frontends/atari/settings.c +++ b/frontends/atari/settings.c @@ -172,7 +172,7 @@ static char **read_locales(void) atari_warn_user("Failed to load locales: %s",buf); return(NULL); } else { - LOG("Reading locales from: %s...", buf); + NSLOG(netsurf, INFO, "Reading locales from: %s...", buf); } /* Count items: */ @@ -257,15 +257,15 @@ static void display_settings(void) /* "Cache" tab: */ tmp_option_memory_cache_size = nsoption_int(memory_cache_size) / (1024*1024); - snprintf( spare, 255, "%d", tmp_option_memory_cache_size ); + snprintf( spare, 255, "%u", tmp_option_memory_cache_size ); set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 4 ); tmp_option_disc_cache_size = nsoption_int(disc_cache_size) / (1024*1024); - snprintf( spare, 255, "%d", tmp_option_disc_cache_size ); + snprintf( spare, 255, "%u", tmp_option_disc_cache_size ); set_text( SETTINGS_STR_MAX_DISC_CACHE, spare, 4 ); tmp_option_disc_cache_age = nsoption_int(disc_cache_age); - snprintf( spare, 255, "%02d", tmp_option_disc_cache_age ); + snprintf( spare, 255, "%02u", tmp_option_disc_cache_age ); set_text( SETTINGS_EDIT_CACHE_AGE, spare, 3 ); /* "Paths" tab: */ @@ -303,7 +303,7 @@ static void display_settings(void) // TODO: activate this option? tmp_option_min_reflow_period = nsoption_int(min_reflow_period); - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); + snprintf( spare, 255, "%04u", tmp_option_min_reflow_period ); set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, INPUT_MIN_REFLOW_PERIOD_MAX_LEN ); @@ -597,7 +597,7 @@ static void form_event(int index, int external) tmp_option_memory_cache_size = 1; if( tmp_option_memory_cache_size > 999 ) tmp_option_memory_cache_size = 999; - snprintf( spare, 255, "%02d", tmp_option_memory_cache_size ); + snprintf( spare, 255, "%02u", tmp_option_memory_cache_size ); set_text( SETTINGS_STR_MAX_MEM_CACHE, spare, 5 ); is_button = true; OBJ_REDRAW(SETTINGS_STR_MAX_MEM_CACHE); @@ -614,7 +614,7 @@ static void form_event(int index, int external) tmp_option_disc_cache_size = 1; if( tmp_option_disc_cache_size > 9999 ) tmp_option_disc_cache_size = 9999; - snprintf( spare, 255, "%02d", tmp_option_disc_cache_size ); + snprintf( spare, 255, "%02u", tmp_option_disc_cache_size ); set_text( SETTINGS_STR_MAX_DISC_CACHE, spare, 5 ); is_button = true; OBJ_REDRAW(SETTINGS_STR_MAX_DISC_CACHE); @@ -630,7 +630,7 @@ static void form_event(int index, int external) if( tmp_option_disc_cache_age > 99 ) tmp_option_disc_cache_age = 0; - snprintf( spare, 255, "%02d", tmp_option_disc_cache_age ); + snprintf( spare, 255, "%02u", tmp_option_disc_cache_age ); set_text( SETTINGS_EDIT_CACHE_AGE, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_CACHE_AGE); @@ -645,7 +645,7 @@ static void form_event(int index, int external) if( tmp_option_max_cached_fetch_handles > 31 ) tmp_option_max_cached_fetch_handles = 31; - snprintf( spare, 255, "%02d", tmp_option_max_cached_fetch_handles ); + snprintf( spare, 255, "%02u", tmp_option_max_cached_fetch_handles ); set_text( SETTINGS_EDIT_MAX_CACHED_CONNECTIONS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_CACHED_CONNECTIONS); @@ -660,7 +660,7 @@ static void form_event(int index, int external) if( tmp_option_max_fetchers > 31 ) tmp_option_max_fetchers = 31; - snprintf( spare, 255, "%02d", tmp_option_max_fetchers ); + snprintf( spare, 255, "%02u", tmp_option_max_fetchers ); set_text( SETTINGS_EDIT_MAX_FETCHERS, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS); @@ -675,7 +675,7 @@ static void form_event(int index, int external) if( tmp_option_max_fetchers_per_host > 31 ) tmp_option_max_fetchers_per_host = 31; - snprintf( spare, 255, "%02d", tmp_option_max_fetchers_per_host ); + snprintf( spare, 255, "%02u", tmp_option_max_fetchers_per_host ); set_text( SETTINGS_EDIT_MAX_FETCHERS_PER_HOST, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MAX_FETCHERS_PER_HOST); @@ -691,7 +691,7 @@ static void form_event(int index, int external) if( tmp_option_expire_url > 99 ) tmp_option_expire_url = 0; - snprintf( spare, 255, "%02d", tmp_option_expire_url ); + snprintf( spare, 255, "%02u", tmp_option_expire_url ); set_text( SETTINGS_EDIT_HISTORY_AGE, spare, 2 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_HISTORY_AGE); @@ -726,7 +726,7 @@ static void form_event(int index, int external) if( tmp_option_font_min_size < 10 ) tmp_option_font_min_size = 10; - snprintf( spare, 255, "%03d", tmp_option_font_min_size ); + snprintf( spare, 255, "%03u", tmp_option_font_min_size ); set_text( SETTINGS_EDIT_MIN_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_FONT_SIZE); @@ -744,7 +744,7 @@ static void form_event(int index, int external) if( tmp_option_font_size < 50 ) tmp_option_font_size = 50; - snprintf( spare, 255, "%03d", tmp_option_font_size ); + snprintf( spare, 255, "%03u", tmp_option_font_size ); set_text( SETTINGS_EDIT_DEF_FONT_SIZE, spare, 3 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_DEF_FONT_SIZE); @@ -760,7 +760,7 @@ static void form_event(int index, int external) if( tmp_option_min_reflow_period > 9999 ) tmp_option_min_reflow_period = 10; - snprintf( spare, 255, "%04d", tmp_option_min_reflow_period ); + snprintf( spare, 255, "%04u", tmp_option_min_reflow_period ); set_text( SETTINGS_EDIT_MIN_REFLOW_PERIOD, spare, 4 ); is_button = true; OBJ_REDRAW(SETTINGS_EDIT_MIN_REFLOW_PERIOD); @@ -980,12 +980,12 @@ void open_settings(void) void close_settings(void) { - LOG("closing"); + NSLOG(netsurf, INFO, "closing"); gemtk_wm_remove(settings_guiwin); settings_guiwin = NULL; wind_close(h_aes_win); wind_delete(h_aes_win); h_aes_win = 0; - LOG("Done"); + NSLOG(netsurf, INFO, "Done"); } diff --git a/frontends/atari/statusbar.c b/frontends/atari/statusbar.c index 3a216f9a8..fe2008c82 100644 --- a/frontends/atari/statusbar.c +++ b/frontends/atari/statusbar.c @@ -166,7 +166,7 @@ CMP_STATUSBAR sb_create( struct gui_window * gw ) void sb_destroy( CMP_STATUSBAR s ) { - LOG("%s\n", __FUNCTION__); + NSLOG(netsurf, INFO, "%s\n", __FUNCTION__); if( s ) { if( s->comp ){ mt_CompDelete( &app, s->comp ); @@ -206,7 +206,7 @@ CMP_STATUSBAR sb_create( struct gui_window * gw ) void sb_destroy( CMP_STATUSBAR s ) { - LOG("%s\n", __FUNCTION__); + NSLOG(netsurf, INFO, "%s\n", __FUNCTION__); if( s ) { free( s ); } diff --git a/frontends/atari/toolbar.c b/frontends/atari/toolbar.c index 9ed87849c..b8f42267f 100644 --- a/frontends/atari/toolbar.c +++ b/frontends/atari/toolbar.c @@ -94,7 +94,7 @@ static float toolbar_url_scale = 1.0; static plot_font_style_t font_style_url = { .family = PLOT_FONT_FAMILY_SANS_SERIF, - .size = 14*FONT_SIZE_SCALE, + .size = 14*PLOT_STYLE_SCALE, .weight = 400, .flags = FONTF_NONE, .background = 0xffffff, @@ -269,7 +269,7 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner) int i; struct s_toolbar *t; - LOG("owner %p", owner); + NSLOG(netsurf, INFO, "owner %p", owner); assert(init == true); @@ -302,7 +302,7 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner) /* create the url widget: */ font_style_url.size = - toolbar_styles[t->style].font_height_pt * FONT_SIZE_SCALE; + toolbar_styles[t->style].font_height_pt * PLOT_STYLE_SCALE; textarea_flags ta_flags = TEXTAREA_INTERNAL_CARET; textarea_setup ta_setup; @@ -327,8 +327,9 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner) t->throbber.max_index = THROBBER_MAX_INDEX; t->throbber.running = false; - LOG("created toolbar: %p, root: %p, textarea: %p, throbber: %p", - t, owner, t->url.textarea, &t->throbber); + NSLOG(netsurf, INFO, + "created toolbar: %p, root: %p, textarea: %p, throbber: %p", t, + owner, t->url.textarea, &t->throbber); return( t ); } @@ -435,7 +436,7 @@ void toolbar_redraw(struct s_toolbar *tb, GRECT *clip) if (rc_intersect(clip, &area)) { float old_scale; - plot_set_dimensions(area_ro.g_x, area_ro.g_y, area_ro.g_w, area_ro.g_h); + plot_set_dimensions(&toolbar_rdrw_ctx, area_ro.g_x, area_ro.g_y, area_ro.g_w, area_ro.g_h); struct rect r = { .x0 = MAX(0,area.g_x - area_ro.g_x), .y0 = MAX(0,area.g_y - area_ro.g_y), @@ -458,7 +459,7 @@ toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw, short button) { - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); struct s_tb_button * bt; bool enable = false; @@ -582,7 +583,7 @@ void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area) void toolbar_set_url(struct s_toolbar *tb, const char *text) { - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); textarea_set_text(tb->url.textarea, text); @@ -668,7 +669,7 @@ bool toolbar_text_input(struct s_toolbar *tb, char *text) { bool handled = true; - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); return(handled); } @@ -757,7 +758,7 @@ void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button) short mx, my, mb, kstat; struct gui_window * gw; - LOG("tb %p", tb); + NSLOG(netsurf, INFO, "tb %p", tb); if (obj==TOOLBAR_AREA_URL) { diff --git a/frontends/atari/treeview.c b/frontends/atari/treeview.c index 93aef6eb6..23db41309 100644 --- a/frontends/atari/treeview.c +++ b/frontends/atari/treeview.c @@ -16,21 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <sys/types.h> -#include <string.h> - #include "assert.h" -#include "cflib.h" -#include "netsurf/inttypes.h" -#include "utils/nsoption.h" #include "utils/log.h" #include "utils/messages.h" -#include "utils/utils.h" -#include "netsurf/plotters.h" -#include "netsurf/mouse.h" +#include "netsurf/inttypes.h" #include "netsurf/core_window.h" -#include "desktop/treeview.h" +#include "netsurf/plotters.h" #include "atari/gui.h" #include "atari/plot/plot.h" @@ -40,30 +32,6 @@ #include "atari/res/netsurf.rsh" -/** - * Declare Core Window Callbacks: - */ - -void atari_treeview_redraw_request(struct core_window *cw, - const struct rect *r); -void atari_treeview_update_size(struct core_window *cw, int width, int height); -void atari_treeview_scroll_visible(struct core_window *cw, - const struct rect *r); -void atari_treeview_get_window_dimensions(struct core_window *cw, - int *width, int *height); - // TODO: implement drag status! -void atari_treeview_drag_status(struct core_window *cw, - core_window_drag_status ds); - -static struct core_window_callback_table cw_t = { - .redraw_request = atari_treeview_redraw_request, - .update_size = atari_treeview_update_size, - .scroll_visible = atari_treeview_scroll_visible, - .get_window_dimensions = atari_treeview_get_window_dimensions, - .drag_status = atari_treeview_drag_status -}; - - struct atari_treeview_window { struct atari_treeview_window * prev_open; struct atari_treeview_window * next_open; @@ -81,23 +49,12 @@ struct atari_treeview_window { static struct atari_treeview_window * treeviews_open; -/* native GUI event handlers: */ -static void on_mbutton_event(struct core_window *cw, EVMULT_OUT *ev_out, - short msg[8]); -static void on_keybd_event(struct core_window *cw, EVMULT_OUT *ev_out, - short msg[8]); -static void on_redraw_event(struct core_window *cw, EVMULT_OUT *ev_out, - short msg[8]); - -/* static utils: */ -//static void atari_treeview_dump_info(struct atari_treeview_window *tv, char *s); - /** * Schedule a redraw of the treeview content * */ -static void atari_treeview_redraw_grect_request(struct core_window *cw, - GRECT *area) +static void +atari_treeview_redraw_grect_request(struct core_window *cw, GRECT *area) { struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; if (cw != NULL) { @@ -115,260 +72,77 @@ static void atari_treeview_redraw_grect_request(struct core_window *cw, int oldy1 = tv->rdw_area.g_y + tv->rdw_area.g_h; tv->rdw_area.g_x = MIN(tv->rdw_area.g_x, area->g_x); tv->rdw_area.g_y = MIN(tv->rdw_area.g_y, area->g_y); - tv->rdw_area.g_w = ( oldx1 > newx1 ) ? oldx1 - tv->rdw_area.g_x : newx1 - tv->rdw_area.g_x; - tv->rdw_area.g_h = ( oldy1 > newy1 ) ? oldy1 - tv->rdw_area.g_y : newy1 - tv->rdw_area.g_y; - } - //dbg_grect("atari_treeview_request_redraw_grect", &tv->rdw_area); - } -} - - -void atari_treeview_get_grect(struct core_window *cw, enum treeview_area_e mode, - GRECT *dest) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + if ( oldx1 > newx1 ) { + tv->rdw_area.g_w = oldx1 - tv->rdw_area.g_x; + } else { + tv->rdw_area.g_w = newx1 - tv->rdw_area.g_x; + } - if (mode == TREEVIEW_AREA_CONTENT) { - gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, dest); - } - else if (mode == TREEVIEW_AREA_TOOLBAR) { - gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_TOOLBAR, dest); + if ( oldy1 > newy1 ) { + tv->rdw_area.g_h = oldy1 - tv->rdw_area.g_y; + } else { + tv->rdw_area.g_h = newy1 - tv->rdw_area.g_y; + } + } + //dbg_grect("atari_treeview_request_redraw_grect", &tv->rdw_area); } } -GUIWIN * atari_treeview_get_gemtk_window(struct core_window *cw) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - return(tv->window); -} -/* -static void atari_treeview_dump_info(struct atari_treeview_window *tv, - char * title) +#ifdef ATARI_TREEVIEW_DUMP +static void +atari_treeview_dump_info(struct atari_treeview_window *tv, char * title) { printf("Treeview Dump (%s)\n", title); printf("=================================\n"); gemtk_wm_dump_window_info(atari_treeview_get_gemtk_window((struct core_window *)tv)); GEMTK_DBG_GRECT("Redraw Area: \n", &tv->rdw_area) - dbg_grect("Redraw Area2: \n", &tv->rdw_area); + dbg_grect("Redraw Area2: \n", &tv->rdw_area); printf("Extent: x: %d, y: %d\n", tv->extent.x, tv->extent.y); } -*/ +#endif -static bool atari_treeview_is_iconified(struct core_window *cw){ - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; +static bool atari_treeview_is_iconified(struct core_window *cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - return((gemtk_wm_get_state(tv->window)&GEMTK_WM_STATUS_ICONIFIED) != 0); + return((gemtk_wm_get_state(tv->window)&GEMTK_WM_STATUS_ICONIFIED) != 0); } -static void atari_treeview_redraw_icon(struct core_window *cw, GRECT *clip) -{ - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - GRECT visible, work; - OBJECT * tree = gemtk_obj_get_tree(ICONIFY); - short aesh = gemtk_wm_get_handle(tv->window); - - gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_WORK, &work); - - tree->ob_x = work.g_x; - tree->ob_y = work.g_y; - tree->ob_width = work.g_w; - tree->ob_height = work.g_h; - - wind_get_grect(aesh, WF_FIRSTXYWH, &visible); - while (visible.g_h > 0 && visible.g_w > 0) { - - if (rc_intersect(&work, &visible)) { - objc_draw(tree, 0, 8, visible.g_x, visible.g_y, visible.g_w, - visible.g_h); - } else { - //dbg_grect("redraw vis area outside", &visible); - } - - wind_get_grect(aesh, WF_NEXTXYWH, &visible); - } -} -void atari_treeview_redraw(struct core_window *cw) +static void atari_treeview_redraw_icon(struct core_window *cw, GRECT *clip) { struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - short pxy[4]; - - if (tv != NULL && tv->is_open) { - if( tv->redraw && ((plot_get_flags() & PLOT_FLAG_OFFSCREEN) == 0) ) { + GRECT visible, work; + OBJECT * tree = gemtk_obj_get_tree(ICONIFY); + short aesh = gemtk_wm_get_handle(tv->window); - short todo[4]; - GRECT work; - short handle = gemtk_wm_get_handle(tv->window); - struct gemtk_wm_scroll_info_s *slid; + gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_WORK, &work); - gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work); - slid = gemtk_wm_get_scroll_info(tv->window); + tree->ob_x = work.g_x; + tree->ob_y = work.g_y; + tree->ob_width = work.g_w; + tree->ob_height = work.g_h; -// // Debug code: this 3 lines help to inspect the redraw -// // areas... -// pxy[0] = work.g_x; -// pxy[1] = work.g_y; -// pxy[2] = pxy[0] + work.g_w-1; -// pxy[3] = pxy[1] + work.g_h-1; -// -// vsf_color(plot_get_vdi_handle(), 0); -// v_bar(plot_get_vdi_handle(), (short*)&pxy); -// evnt_timer(500); + wind_get_grect(aesh, WF_FIRSTXYWH, &visible); + while (visible.g_h > 0 && visible.g_w > 0) { - struct redraw_context ctx = { - .interactive = true, - .background_images = true, - .plot = &atari_plotters - }; - plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h); - if (plot_lock() == false) - return; - - if( wind_get(handle, WF_FIRSTXYWH, - &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) { - while (todo[2] && todo[3]) { - - if(!rc_intersect(&work, (GRECT*)&todo)){ - if (wind_get(handle, WF_NEXTXYWH, - &todo[0], &todo[1], &todo[2], &todo[3])==0) { - break; - } - continue; - } - pxy[0] = todo[0]; - pxy[1] = todo[1]; - pxy[2] = todo[0] + todo[2]-1; - pxy[3] = todo[1] + todo[3]-1; - vs_clip(plot_get_vdi_handle(), 1, (short*)&pxy); - - // Debug code: this 3 lines help to inspect the redraw - // areas... - -// vsf_color(plot_get_vdi_handle(), 3); -// v_bar(plot_get_vdi_handle(), (short*)&pxy); -// evnt_timer(500); - - - /* convert screen to treeview coords: */ - todo[0] = todo[0] - work.g_x ;//+ slid->x_pos*slid->x_unit_px; - todo[1] = todo[1] - work.g_y ;//+ slid->y_pos*slid->y_unit_px; - if( todo[0] < 0 ){ - todo[2] = todo[2] + todo[0]; - todo[0] = 0; - } - if( todo[1] < 0 ){ - todo[3] = todo[3] + todo[1]; - todo[1] = 0; - } - - if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) { - struct rect clip; - - clip.x0 = todo[0]+(slid->x_pos*slid->x_unit_px); - clip.y0 = todo[1]+(slid->y_pos*slid->y_unit_px); - clip.x1 = clip.x0 + todo[2]+(slid->x_pos*slid->x_unit_px); - clip.y1 = clip.y0 + todo[3]+(slid->y_pos*slid->y_unit_px); - - tv->io->draw(cw, -(slid->x_pos*slid->x_unit_px), - -(slid->y_pos*slid->y_unit_px), - &clip, &ctx); - } - vs_clip(plot_get_vdi_handle(), 0, (short*)&pxy); - if (wind_get(handle, WF_NEXTXYWH, - &todo[0], &todo[1], &todo[2], &todo[3])==0) { - break; - } - } - } else { - plot_unlock(); - return; - } - plot_unlock(); - tv->redraw = false; - tv->rdw_area.g_x = 65000; - tv->rdw_area.g_y = 65000; - tv->rdw_area.g_w = -1; - tv->rdw_area.g_h = -1; + if (rc_intersect(&work, &visible)) { + objc_draw(tree, 0, 8, visible.g_x, visible.g_y, visible.g_w, + visible.g_h); } else { - /* just copy stuff from the offscreen buffer */ + //dbg_grect("redraw vis area outside", &visible); } - } -} - -/** - * GEMTK (netsurf's GEM toolkit) event sink - * -*/ -static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) -{ - short retval = 0; - struct atari_treeview_window *tv = (struct atari_treeview_window *) - gemtk_wm_get_user_data(win); - struct core_window *cw = (struct core_window *)tv; - - if( (ev_out->emo_events & MU_MESAG) != 0 ) { - // handle message - switch (msg[0]) { - - case WM_REDRAW: - on_redraw_event(cw, ev_out, msg); - break; - - default: - break; - } - } - if( (ev_out->emo_events & MU_KEYBD) != 0 ) { - on_keybd_event(cw, ev_out, msg); - } - if( (ev_out->emo_events & MU_BUTTON) != 0 ) { - LOG("Treeview click at: %d,%d\n", ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y); - on_mbutton_event(cw, ev_out, msg); - } - - if(tv != NULL && tv->io->gemtk_user_func != NULL){ - tv->io->gemtk_user_func(win, ev_out, msg); - } - - // TODO: evaluate return values of event handler functions and pass them on: - return(retval); -} - - -static void __CDECL on_keybd_event(struct core_window *cw, EVMULT_OUT *ev_out, - short msg[8]) -{ - long kstate = 0; - long kcode = 0; - long ucs4; - long ik; - unsigned short nkc = 0; - unsigned char ascii; - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - - kstate = ev_out->emo_kmeta; - kcode = ev_out->emo_kreturn; - nkc= gem_to_norm( (short)kstate, (short)kcode ); - ascii = (nkc & 0xFF); - ik = nkc_to_input_key(nkc, &ucs4); - - if (ik == 0) { - if (ascii >= 9) { - tv->io->keypress(cw, ucs4); - } - } else { - tv->io->keypress(cw, ik); + wind_get_grect(aesh, WF_NEXTXYWH, &visible); } } -static void __CDECL on_redraw_event(struct core_window *cw, - EVMULT_OUT *ev_out, - short msg[8]) +static void __CDECL +on_redraw_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8]) { GRECT work, clip; struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; @@ -425,9 +199,9 @@ static void __CDECL on_redraw_event(struct core_window *cw, } } -static void __CDECL on_mbutton_event(struct core_window *cw, - EVMULT_OUT *ev_out, - short msg[8]) + +static void __CDECL +on_mbutton_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8]) { struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; struct gemtk_wm_scroll_info_s *slid; @@ -444,26 +218,26 @@ static void __CDECL on_mbutton_event(struct core_window *cw, /* mouse click relative origin: */ - short origin_rel_x = (mx-work.g_x) + - (slid->x_pos*slid->x_unit_px); - short origin_rel_y = (my-work.g_y) + - (slid->y_pos*slid->y_unit_px); + short origin_rel_x = (mx-work.g_x) + (slid->x_pos*slid->x_unit_px); + short origin_rel_y = (my-work.g_y) + (slid->y_pos*slid->y_unit_px); /* Only pass on events in the content area: */ - if( origin_rel_x >= 0 && origin_rel_y >= 0 - && mx < work.g_x + work.g_w - && my < work.g_y + work.g_h ) - { + if ((origin_rel_x >= 0) && + (origin_rel_y >= 0) && + (mx < work.g_x + work.g_w) && + (my < work.g_y + work.g_h)) { if (ev_out->emo_mclicks == 2) { tv->io->mouse_action(cw, - BROWSER_MOUSE_CLICK_1|BROWSER_MOUSE_DOUBLE_CLICK, - origin_rel_x, origin_rel_y); + BROWSER_MOUSE_CLICK_1 | + BROWSER_MOUSE_DOUBLE_CLICK, + origin_rel_x, + origin_rel_y); return; } graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy); /* check for click or hold: */ - if( (mbut&1) == 0 ){ + if ((mbut & 1) == 0 ) { int bms; bms = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1; if(ev_out->emo_mclicks == 2 ) { @@ -483,43 +257,282 @@ static void __CDECL on_mbutton_event(struct core_window *cw, tv->startdrag.x = origin_rel_x; tv->startdrag.y = origin_rel_y; /* First, report mouse press, to trigger entry selection */ - tv->io->mouse_action(cw, BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1, cur_rel_x, - cur_rel_y); + tv->io->mouse_action(cw, + BROWSER_MOUSE_CLICK_1 | + BROWSER_MOUSE_PRESS_1, + cur_rel_x, + cur_rel_y); atari_treeview_redraw(cw); - tv->io->mouse_action(cw, BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_ON, - cur_rel_x, cur_rel_y); - do{ - if (abs(prev_x-cur_rel_x) > 5 || abs(prev_y-cur_rel_y) > 5) { + tv->io->mouse_action(cw, + BROWSER_MOUSE_DRAG_1 | + BROWSER_MOUSE_DRAG_ON, + cur_rel_x, + cur_rel_y); + do { + if (abs(prev_x-cur_rel_x) > 5 || + abs(prev_y-cur_rel_y) > 5) { tv->io->mouse_action(cw, - BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON, - cur_rel_x, cur_rel_y); + BROWSER_MOUSE_HOLDING_1 | + BROWSER_MOUSE_DRAG_ON, + cur_rel_x, + cur_rel_y); prev_x = cur_rel_x; prev_y = cur_rel_y; } if (tv->redraw) { // TODO: maybe GUI poll would fit better here? - // ... is gui_poll re-entrance save? + // ... is gui_poll re-entrance save? atari_treeview_redraw(cw); } /* sample mouse button state: */ - graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy); - cur_rel_x = (cur_rel_x-work.g_x)+(slid->x_pos*slid->x_unit_px); - cur_rel_y = (cur_rel_y-work.g_y)+(slid->y_pos*slid->y_unit_px); - } while( mbut & 1 ); + graf_mkstate(&cur_rel_x, + &cur_rel_y, + &mbut, + &dummy); + cur_rel_x = (cur_rel_x-work.g_x) + + (slid->x_pos*slid->x_unit_px); + cur_rel_y = (cur_rel_y-work.g_y) + + (slid->y_pos*slid->y_unit_px); + } while (mbut & 1); /* End drag: */ - tv->io->mouse_action(cw, BROWSER_MOUSE_HOVER, cur_rel_x, cur_rel_y); + tv->io->mouse_action(cw, + BROWSER_MOUSE_HOVER, + cur_rel_x, + cur_rel_y); gem_set_cursor(&gem_cursors.arrow); } } } +static void __CDECL +on_keybd_event(struct core_window *cw, EVMULT_OUT *ev_out, short msg[8]) +{ + long kstate = 0; + long kcode = 0; + long ucs4; + long ik; + unsigned short nkc = 0; + unsigned char ascii; + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + + kstate = ev_out->emo_kmeta; + kcode = ev_out->emo_kreturn; + nkc= gem_to_norm( (short)kstate, (short)kcode ); + ascii = (nkc & 0xFF); + ik = nkc_to_input_key(nkc, &ucs4); + + if (ik == 0) { + if (ascii >= 9) { + tv->io->keypress(cw, ucs4); + } + } else { + tv->io->keypress(cw, ik); + } +} + + +/** + * GEMTK (netsurf's GEM toolkit) event sink + * + */ +static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]) +{ + short retval = 0; + struct atari_treeview_window *tv = (struct atari_treeview_window *) + gemtk_wm_get_user_data(win); + struct core_window *cw = (struct core_window *)tv; + + if( (ev_out->emo_events & MU_MESAG) != 0 ) { + // handle message + switch (msg[0]) { + + case WM_REDRAW: + on_redraw_event(cw, ev_out, msg); + break; + + default: + break; + } + } + if ((ev_out->emo_events & MU_KEYBD) != 0 ) { + on_keybd_event(cw, ev_out, msg); + } + if ((ev_out->emo_events & MU_BUTTON) != 0 ) { + NSLOG(netsurf, INFO, "Treeview click at: %d,%d\n", + ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y); + on_mbutton_event(cw, ev_out, msg); + } + + if (tv != NULL && tv->io->gemtk_user_func != NULL){ + tv->io->gemtk_user_func(win, ev_out, msg); + } + + // TODO: evaluate return values of event handler functions and pass them on: + return(retval); +} + + +/** + * callback from core to request an invalidation of a window area. + * + * The specified area of the window should now be considered + * out of date. If the area is NULL the entire window must be + * invalidated. + * + * \param[in] cw The core window to invalidate. + * \param[in] r area to redraw or NULL for the entire window area. + * \return NSERROR_OK on success or appropriate error code. + */ +static nserror +atari_treeview_invalidate_area(struct core_window *cw, + const struct rect *r) +{ + GRECT area; + struct gemtk_wm_scroll_info_s * slid; + struct atari_treeview_window * tv = (struct atari_treeview_window *)cw; + + assert(tv); + + if (r != NULL) { + RECT_TO_GRECT(r, &area); + + slid = gemtk_wm_get_scroll_info(tv->window); + + //dbg_rect("redraw rect request", r); + + // treeview redraw is always full window width: + area.g_x = 0; + area.g_w = 8000; + // but vertical redraw region is clipped: + area.g_y = r->y0 - (slid->y_pos*slid->y_unit_px); + area.g_h = r->y1 - r->y0; + } else { + atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &area); + } + atari_treeview_redraw_grect_request(cw, &area); + + return NSERROR_OK; +} + + +/** + * Update the limits of the window + * + * \param cw the core window object + * \param width the width in px, or negative if don't care + * \param height the height in px, or negative if don't care + */ +static void +atari_treeview_update_size(struct core_window *cw, int width, int height) +{ + GRECT area; + struct gemtk_wm_scroll_info_s *slid; + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + + if (tv != NULL) { + + if (tv->disposing) + return; + + /* Get acces to the gemtk window slider settings: */ + slid = gemtk_wm_get_scroll_info(tv->window); + + /* recalculate and refresh sliders: */ + atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &area); + if (width > -1) { + slid->x_units = (width/slid->x_unit_px); + } else { + slid->x_units = 1; + } + + if (height > -1) { + slid->y_units = (height/slid->y_unit_px); + } else { + slid->y_units = 1; + } + + tv->extent.x = width; + tv->extent.y = height; + + + /* printf("units content: %d, units viewport: %d\n", + (height/slid->y_unit_px), + (area.g_h/slid->y_unit_px)); + */ + gemtk_wm_update_slider(tv->window, GEMTK_WM_VH_SLIDER); + } +} + + +/** + * Scroll the window to make area visible + * + * \param cw the core window object + * \param r rectangle to make visible + */ +static void +atari_treeview_scroll_visible(struct core_window *cw, const struct rect *r) +{ + /* atari frontend doesn't support dragging outside the treeview */ + /* so there is no need to implement this? */ +} + + +/** + * Get window viewport dimensions + * + * \param cw the core window object + * \param width to be set to viewport width in px, if non NULL + * \param height to be set to viewport height in px, if non NULL + */ +static void +atari_treeview_get_window_dimensions(struct core_window *cw, + int *width, + int *height) +{ + if ((cw != NULL) && + (width != NULL || height != NULL)) { + GRECT work; + atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &work); + *width = work.g_w; + *height = work.g_h; + } +} + + +/** + * Inform corewindow owner of drag status + * + * \param cw the core window object + * \param ds the current drag status + */ +static void +atari_treeview_drag_status(struct core_window *cw, core_window_drag_status ds) +{ + +} + + +/** + * Declare Core Window Callbacks: + */ +static struct core_window_callback_table cw_t = { + .invalidate = atari_treeview_invalidate_area, + .update_size = atari_treeview_update_size, + .scroll_visible = atari_treeview_scroll_visible, + .get_window_dimensions = atari_treeview_get_window_dimensions, + .drag_status = atari_treeview_drag_status +}; + + +/* exported interface documented in atari/treeview.h */ struct core_window * atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks, - void * user_data, uint32_t flags) + void * user_data, uint32_t flags) { /* allocate the core_window struct: */ @@ -528,7 +541,7 @@ atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks, tv = calloc(1, sizeof(struct atari_treeview_window)); if (tv == NULL) { - LOG("calloc failed"); + NSLOG(netsurf, INFO, "calloc failed"); atari_warn_user(messages_get_errorcode(NSERROR_NOMEM), 0); return NULL; } @@ -555,12 +568,12 @@ atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks, assert(tv->io); assert(tv->io->init_phase2); - /* Now that the window is configured for treeview content, */ - /* call init_phase2 which must create the treeview */ - /* descriptor, and at least setup the the default */ - /* event handlers of the treeview: */ - /* It would be more simple to not pass around the callbacks */ - /* but the treeview constructor requires them for initialization... */ + /* Now that the window is configured for treeview content, */ + /* call init_phase2 which must create the treeview */ + /* descriptor, and at least setup the the default */ + /* event handlers of the treeview: */ + /* It would be more simple to not pass around the callbacks */ + /* but the treeview constructor requires them for initialization... */ nserror err = tv->io->init_phase2((struct core_window *)tv, &cw_t); if (err != NSERROR_OK) { free(tv); @@ -570,6 +583,147 @@ atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks, return((struct core_window *)tv); } + +/* exported interface documented in atari/treeview.h */ +void +atari_treeview_get_grect(struct core_window *cw, + enum treeview_area_e mode, + GRECT *dest) +{ + + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + + if (mode == TREEVIEW_AREA_CONTENT) { + gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, dest); + } + else if (mode == TREEVIEW_AREA_TOOLBAR) { + gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_TOOLBAR, dest); + } +} + + +/* exported interface documented in atari/treeview.h */ +GUIWIN * atari_treeview_get_gemtk_window(struct core_window *cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + return(tv->window); +} + + +/* exported interface documented in atari/treeview.h */ +void atari_treeview_redraw(struct core_window *cw) +{ + struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; + short pxy[4]; + + if (tv != NULL && tv->is_open) { + if( tv->redraw && ((plot_get_flags() & PLOT_FLAG_OFFSCREEN) == 0) ) { + + short todo[4]; + GRECT work; + short handle = gemtk_wm_get_handle(tv->window); + struct gemtk_wm_scroll_info_s *slid; + + gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_CONTENT, &work); + slid = gemtk_wm_get_scroll_info(tv->window); + +// // Debug code: this 3 lines help to inspect the redraw +// // areas... +// pxy[0] = work.g_x; +// pxy[1] = work.g_y; +// pxy[2] = pxy[0] + work.g_w-1; +// pxy[3] = pxy[1] + work.g_h-1; +// +// vsf_color(plot_get_vdi_handle(), 0); +// v_bar(plot_get_vdi_handle(), (short*)&pxy); +// evnt_timer(500); + + struct redraw_context ctx = { + .interactive = true, + .background_images = true, + .plot = &atari_plotters + }; + plot_set_dimensions(&ctx, + work.g_x, + work.g_y, + work.g_w, + work.g_h); + if (plot_lock() == false) + return; + + if( wind_get(handle, WF_FIRSTXYWH, + &todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) { + while (todo[2] && todo[3]) { + + if(!rc_intersect(&work, (GRECT*)&todo)){ + if (wind_get(handle, WF_NEXTXYWH, + &todo[0], &todo[1], &todo[2], &todo[3])==0) { + break; + } + continue; + } + pxy[0] = todo[0]; + pxy[1] = todo[1]; + pxy[2] = todo[0] + todo[2]-1; + pxy[3] = todo[1] + todo[3]-1; + vs_clip(plot_get_vdi_handle(), 1, (short*)&pxy); + + // Debug code: this 3 lines help to inspect the redraw + // areas... + +// vsf_color(plot_get_vdi_handle(), 3); +// v_bar(plot_get_vdi_handle(), (short*)&pxy); +// evnt_timer(500); + + + /* convert screen to treeview coords: */ + todo[0] = todo[0] - work.g_x ;//+ slid->x_pos*slid->x_unit_px; + todo[1] = todo[1] - work.g_y ;//+ slid->y_pos*slid->y_unit_px; + if( todo[0] < 0 ){ + todo[2] = todo[2] + todo[0]; + todo[0] = 0; + } + if( todo[1] < 0 ){ + todo[3] = todo[3] + todo[1]; + todo[1] = 0; + } + + if (rc_intersect((GRECT *)&tv->rdw_area,(GRECT *)&todo)) { + struct rect clip; + + clip.x0 = todo[0]+(slid->x_pos*slid->x_unit_px); + clip.y0 = todo[1]+(slid->y_pos*slid->y_unit_px); + clip.x1 = clip.x0 + todo[2]+(slid->x_pos*slid->x_unit_px); + clip.y1 = clip.y0 + todo[3]+(slid->y_pos*slid->y_unit_px); + + tv->io->draw(cw, -(slid->x_pos*slid->x_unit_px), + -(slid->y_pos*slid->y_unit_px), + &clip, &ctx); + } + vs_clip(plot_get_vdi_handle(), 0, (short*)&pxy); + if (wind_get(handle, WF_NEXTXYWH, + &todo[0], &todo[1], &todo[2], &todo[3])==0) { + break; + } + } + } else { + plot_unlock(); + return; + } + plot_unlock(); + tv->redraw = false; + tv->rdw_area.g_x = 65000; + tv->rdw_area.g_y = 65000; + tv->rdw_area.g_w = -1; + tv->rdw_area.g_h = -1; + } else { + /* just copy stuff from the offscreen buffer */ + } + } +} + + +/* exported interface documented in atari/treeview.h */ void atari_treeview_delete(struct core_window * cw) { struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; @@ -583,6 +737,7 @@ void atari_treeview_delete(struct core_window * cw) } +/* exported interface documented in atari/treeview.h */ void atari_treeview_open(struct core_window *cw, GRECT *pos) { struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; @@ -607,25 +762,32 @@ void atari_treeview_open(struct core_window *cw, GRECT *pos) } } + +/* exported interface documented in atari/treeview.h */ bool atari_treeview_is_open(struct core_window *cw) { struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; return(tv->is_open); } -void atari_treeview_set_user_data(struct core_window * cw, - void *user_data_ptr) + +/* exported interface documented in atari/treeview.h */ +void atari_treeview_set_user_data(struct core_window *cw, void *user_data_ptr) { struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; tv->user_data = user_data_ptr; } + +/* exported interface documented in atari/treeview.h */ void * atari_treeview_get_user_data(struct core_window * cw) { struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; return(tv->user_data); } + +/* exported interface documented in atari/treeview.h */ void atari_treeview_close(struct core_window *cw) { struct atari_treeview_window *tv = (struct atari_treeview_window*)cw; @@ -646,150 +808,24 @@ void atari_treeview_close(struct core_window *cw) } -/** - * Core Window Callbacks: - */ - -/** - * Request a redraw of the window - * - * \param cw the core window object - * \param r rectangle to redraw - */ -void atari_treeview_redraw_request(struct core_window *cw, const struct rect *r) -{ - GRECT area; - struct gemtk_wm_scroll_info_s * slid; - struct atari_treeview_window * tv = (struct atari_treeview_window *)cw; - - RECT_TO_GRECT(r, &area) - - assert(tv); - - slid = gemtk_wm_get_scroll_info(tv->window); - - //dbg_rect("redraw rect request", r); - - // treeview redraw is always full window width: - area.g_x = 0; - area.g_w = 8000; - // but vertical redraw region is clipped: - area.g_y = r->y0 - (slid->y_pos*slid->y_unit_px); - area.g_h = r->y1 - r->y0; - atari_treeview_redraw_grect_request(cw, &area); -} - -/** - * Update the limits of the window - * - * \param cw the core window object - * \param width the width in px, or negative if don't care - * \param height the height in px, or negative if don't care - */ -void atari_treeview_update_size(struct core_window *cw, int width, int height) -{ - GRECT area; - struct gemtk_wm_scroll_info_s *slid; - struct atari_treeview_window *tv = (struct atari_treeview_window *)cw; - - if (tv != NULL) { - - if (tv->disposing) - return; - - /* Get acces to the gemtk window slider settings: */ - slid = gemtk_wm_get_scroll_info(tv->window); - - /* recalculate and refresh sliders: */ - atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &area); - if (width > -1) { - slid->x_units = (width/slid->x_unit_px); - } else { - slid->x_units = 1; - } - - if (height > -1) { - slid->y_units = (height/slid->y_unit_px); - } else { - slid->y_units = 1; - } - - tv->extent.x = width; - tv->extent.y = height; - - - /*printf("units content: %d, units viewport: %d\n", (height/slid->y_unit_px), - (area.g_h/slid->y_unit_px));*/ - gemtk_wm_update_slider(tv->window, GEMTK_WM_VH_SLIDER); - } -} - - -/** - * Scroll the window to make area visible - * - * \param cw the core window object - * \param r rectangle to make visible - */ -void atari_treeview_scroll_visible(struct core_window *cw, const struct rect *r) -{ - /* atari frontend doesn't support dragging outside the treeview */ - /* so there is no need to implement this? */ -} - - -/** - * Get window viewport dimensions - * - * \param cw the core window object - * \param width to be set to viewport width in px, if non NULL - * \param height to be set to viewport height in px, if non NULL - */ -void atari_treeview_get_window_dimensions(struct core_window *cw, - int *width, int *height) -{ - if (cw != NULL && (width != NULL || height != NULL)) { - GRECT work; - atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &work); - *width = work.g_w; - *height = work.g_h; - } -} - - -/** - * Inform corewindow owner of drag status - * - * \param cw the core window object - * \param ds the current drag status - */ -void atari_treeview_drag_status(struct core_window *cw, - core_window_drag_status ds) -{ - -} - +/* exported interface documented in atari/treeview.h */ void atari_treeview_flush_redraws(void) { struct atari_treeview_window *tmp; tmp = treeviews_open; - if(tmp){ - while(tmp){ - assert(tmp->is_open); - if(tmp->redraw){ - if (atari_treeview_is_iconified((struct core_window *)tmp)) { - /* No content redraw for iconified windows */ - /* because otherwise the icon draw function would */ - /* have to deal with plot canvas coords */ - continue; - } - - atari_treeview_redraw((struct core_window *)tmp); - } - tmp = tmp->next_open; + while (tmp != NULL) { + assert(tmp->is_open); + if (tmp->redraw && + (!atari_treeview_is_iconified((struct core_window *)tmp))) { + /* Content redraw only for iconified windows + * because otherwise the icon draw function + * would have to deal with plot canvas coords + */ + atari_treeview_redraw((struct core_window *)tmp); } + tmp = tmp->next_open; } -} +} diff --git a/frontends/atari/treeview.h b/frontends/atari/treeview.h index d10129eaa..fe267b122 100644 --- a/frontends/atari/treeview.h +++ b/frontends/atari/treeview.h @@ -68,7 +68,7 @@ struct atari_treeview_callbacks { /** * Initalize an window to be an treeview window. * -*/ + */ struct core_window *atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks * callbacks, void * user_data, uint32_t flags); /** diff --git a/frontends/atari/verify_ssl.c b/frontends/atari/verify_ssl.c index 055fd3057..b099fe488 100644 --- a/frontends/atari/verify_ssl.c +++ b/frontends/atari/verify_ssl.c @@ -80,7 +80,9 @@ static void __CDECL cert_info_draw( WINDOW * win, short buf[8], void * data) if( line == NULL ) return; - LOG("Cert info draw, win: %p, data: %p, scrollx: %d", win, data, dp->scrollx ); + NSLOG(netsurf, INFO, + "Cert info draw, win: %p, data: %p, scrollx: %d", win, data, + dp->scrollx); WindGet( win, WF_WORKXYWH, &x, &y, &w, &h ); /*using static values here, as RsrcUserDraw has mem leaks & a very small stack */ @@ -158,7 +160,7 @@ static void do_popup( WINDOW *win, int index, int mode, void *data) char * items[dp->num_certs]; short x, y; unsigned int i; - LOG("do_popup: num certs: %d", dp->num_certs); + NSLOG(netsurf, INFO, "do_popup: num certs: %d", dp->num_certs); for( i = 0; i<dp->num_certs; i++) { items[i] = malloc( 48 ); strncpy(items[i], (char*)&dp->cert_infos_n[i].issuer, 46 ); @@ -182,8 +184,10 @@ static void do_popup( WINDOW *win, int index, int mode, void *data) -bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_infos_n , - unsigned long num_certs ) +bool +verify_ssl_form_do(const char * url, + const struct ssl_cert_info * cert_infos_n, + unsigned long num_certs) { OBJECT *tree; WINDOW * form; @@ -191,6 +195,13 @@ bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_inf bool bres = false; bool cont = true; int res = 0; + + RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree); + ObjcString( tree, VERIFY_LBL_HOST, (char*)url ); + ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 ); + ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 ); + form = FormWindBegin( tree, (char*)"SSL Verify failed" ); + dp.cert_infos_n = (struct ssl_cert_info *)cert_infos_n; dp.num_certs = num_certs; dp.scrollx = 0; @@ -199,12 +210,6 @@ bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_inf dp.cols = cert_display_width( &dp.cert_infos_n[dp.current] ); dp.rows = 8; dp.tree = tree; - - RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree); - ObjcString( tree, VERIFY_LBL_HOST, (char*)url ); - ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 ); - ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 ); - form = FormWindBegin( tree, (char*)"SSL Verify failed" ); EvntDataAdd( form, WM_REDRAW, cert_info_draw, (void*)&dp, EV_BOT ); /* this results in some extended objects which can not be freed: :( */ /* RsrcUserDraw( OC_FORM, tree, VERIFY_BOX_DETAILS, cert_info_draw,(void*)&dp ) ; */ @@ -243,7 +248,7 @@ bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_inf break; case VERIFY_BT_SCROLL_R: - LOG("scroll r!"); + NSLOG(netsurf, INFO, "scroll r!"); cont = true; dp.scrollx += 1; if( dp.scrollx > (dp.cols - (272 / 8 )) ) |