summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--riscos/buffer.c78
-rw-r--r--riscos/options.h3
-rw-r--r--riscos/tinct.h2
3 files changed, 45 insertions, 38 deletions
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 <stdbool.h>
#include <stdlib.h>
#include <string.h>
+#include <swis.h>
#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;
}
diff --git a/riscos/options.h b/riscos/options.h
index 559be505b..2f1b76229 100644
--- a/riscos/options.h
+++ b/riscos/options.h
@@ -59,7 +59,6 @@ extern int option_font_default; /* a css_font_family */
extern char *option_font_default_italic;
extern char *option_font_default_bold;
extern char *option_font_default_bold_italic;
-extern int option_screen_cache;
extern bool option_block_popups;
extern bool option_url_suggestion;
@@ -102,7 +101,6 @@ char *option_font_mono = 0; \
char *option_font_cursive = 0; \
char *option_font_fantasy = 0; \
int option_font_default = CSS_FONT_FAMILY_SANS_SERIF; \
-int option_screen_cache = 0; \
bool option_block_popups = false; \
bool option_url_suggestion = true;
@@ -145,7 +143,6 @@ bool option_url_suggestion = true;
{ "font_cursive", OPTION_STRING, &option_font_cursive }, \
{ "font_fantasy", OPTION_STRING, &option_font_fantasy }, \
{ "font_default", OPTION_INTEGER, &option_font_default }, \
-{ "screen_cache", OPTION_INTEGER, &option_screen_cache }, \
{ "block_popups", OPTION_BOOL, &option_block_popups }, \
{ "url_suggestion", OPTION_BOOL, &option_url_suggestion }
diff --git a/riscos/tinct.h b/riscos/tinct.h
index 2a1a4a44e..376546a62 100644
--- a/riscos/tinct.h
+++ b/riscos/tinct.h
@@ -61,5 +61,5 @@
/* Sprite mode
*/
-#define tinct_SPRITE_MODE 0x301680b5
+#define tinct_SPRITE_MODE (os_mode)0x301680b5
#endif