From d8c19f2e13dfdc404a357163ee75a35396ad5af6 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Sun, 10 Apr 2005 23:26:17 +0000 Subject: [project @ 2005-04-10 23:26:17 by rjw] Remove screen cache, workaround SpriteExtend bug. svn path=/import/netsurf/; revision=1622 --- riscos/buffer.c | 78 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 34 deletions(-) (limited to 'riscos/buffer.c') diff --git a/riscos/buffer.c b/riscos/buffer.c index 30abd4c6d..ea14444dc 100644 --- a/riscos/buffer.c +++ b/riscos/buffer.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "oslib/colourtrans.h" #include "oslib/os.h" #include "oslib/osspriteop.h" @@ -15,10 +16,12 @@ #include "oslib/wimpreadsysinfo.h" #include "netsurf/riscos/buffer.h" #include "netsurf/riscos/options.h" +#include "netsurf/riscos/tinct.h" #include "netsurf/riscos/wimp.h" #include "netsurf/utils/log.h" //#define NDEBUG #define BUFFER_EXCLUSIVE_USER_REDRAW "Only support pure user redraw (faster)" +//#define BUFFER_EMULATE_32BPP "Redirect to a 32bpp sprite and plot with Tinct" /* SCREEN BUFFERING ================ @@ -42,7 +45,6 @@ static void ro_gui_buffer_free(void); /** The buffer characteristics */ -static bool buffer_active = false; static osspriteop_area *buffer = NULL; static char buffer_name[] = "scr_buffer\0\0"; @@ -57,6 +59,9 @@ static osspriteop_area *context1; static osspriteop_id context2; static osspriteop_save_area *context3; +/** The current sprite mode +*/ +static os_mode mode; /** * Opens a buffer for writing to. @@ -72,15 +77,13 @@ void ro_gui_buffer_open(wimp_draw *redraw) { bool palette; os_error *error; int palette_size = 0; - int claim_size; #ifdef BUFFER_EXCLUSIVE_USER_REDRAW - os_mode mode; osspriteop_header *header; #endif /* Close any open buffer */ - if (buffer_active) + if (buffer) ro_gui_buffer_close(); /* Store our clipping region @@ -92,11 +95,19 @@ void ro_gui_buffer_open(wimp_draw *redraw) { sprite_size.x = clipping.x1 - clipping.x0 + 1; sprite_size.y = clipping.y1 - clipping.y0 + 1; ro_convert_os_units_to_pixels(&sprite_size, (os_mode)-1); + if (sprite_size.y == 1) /* work around SpriteExtend bug */ + sprite_size.y = 2; + +#ifdef BUFFER_EMULATE_32BPP + bpp = 5; + palette = false; +#else /* Get the screen depth as we can't use palettes for >8bpp */ xos_read_mode_variable((os_mode)-1, os_MODEVAR_LOG2_BPP, &bpp, 0); palette = (bpp < 4); +#endif /* Get our required buffer size */ @@ -105,30 +116,29 @@ void ro_gui_buffer_open(wimp_draw *redraw) { palette_size = ((1 << (1 << bpp)) << 3); total_size = sizeof(osspriteop_area) + sizeof(osspriteop_header) + (word_width * sprite_size.y * 4) + palette_size; + buffer = (osspriteop_area *)malloc(total_size); + if (!buffer) { + LOG(("Failed to allocate memory")); + return; + } + buffer->size = total_size; + buffer->first = 16; - if ((buffer == NULL) || (total_size > buffer->size)) { - claim_size = (total_size > (option_screen_cache << 10)) ? - total_size : (option_screen_cache << 10); - if (buffer) - free(buffer); - buffer = (osspriteop_area *)malloc(claim_size); - if (!buffer) { - LOG(("Failed to allocate memory")); +#ifdef BUFFER_EMULATE_32BPP + mode = tinct_SPRITE_MODE; +#else + if (bpp == 32) { + mode = tinct_SPRITE_MODE; + } else { + if ((error = xwimpreadsysinfo_wimp_mode(&mode)) != NULL) { + LOG(("Error reading mode '%s'", error->errmess)); + ro_gui_buffer_free(); return; } - buffer->size = claim_size; - buffer->first = 16; } +#endif - /* Set the sprite area details - */ #ifdef BUFFER_EXCLUSIVE_USER_REDRAW - if ((error = xwimpreadsysinfo_wimp_mode(&mode)) != NULL) { - LOG(("Error reading mode '%s'", error->errmess)); - ro_gui_buffer_free(); - return; - } - /* Create the sprite manually so we don't waste time clearing the background. */ @@ -199,7 +209,6 @@ void ro_gui_buffer_open(wimp_draw *redraw) { os_writec((char)29); os_writec(orig_x0 & 0xff); os_writec(orig_x0 >> 8); os_writec(orig_y0 & 0xff); os_writec(orig_y0 >> 8); - buffer_active = true; } @@ -210,7 +219,7 @@ void ro_gui_buffer_close(void) { /* Check we have an open buffer */ - if (!buffer_active) + if (!buffer) return; /* Remove any previous redirection @@ -222,11 +231,16 @@ void ro_gui_buffer_close(void) { /* Plot the contents to screen */ - xosspriteop_put_sprite_user_coords(osspriteop_PTR, - buffer, (osspriteop_id)(buffer + 1), - clipping.x0, clipping.y0, (os_action)0); + if (mode == tinct_SPRITE_MODE) + _swix(Tinct_Plot, _IN(2) | _IN(3) | _IN(4) | _IN(7), + (char *)(buffer + 1), + clipping.x0, clipping.y0, + option_fg_plot_style); + else + xosspriteop_put_sprite_user_coords(osspriteop_PTR, + buffer, (osspriteop_id)(buffer + 1), + clipping.x0, clipping.y0, (os_action)0); ro_gui_buffer_free(); - buffer_active = false; } @@ -234,10 +248,6 @@ void ro_gui_buffer_close(void) { * Releases any buffer memory depending on cache constraints. */ static void ro_gui_buffer_free(void) { - if (buffer == NULL) - return; - if (buffer->size > (option_screen_cache << 10)) { - free(buffer); - buffer = NULL; - } + free(buffer); + buffer = NULL; } -- cgit v1.2.3