From 143e553593477ba42ecbda9858436e66aaf56d2c Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 3 Oct 2013 19:25:01 +0100 Subject: Remove redundant bitmap compression/decompression/dropping-to-disc. The core now has a converted bitmap cache that is pruned more agressively. --- riscos/Makefile.target | 2 +- riscos/bitmap.c | 527 +----------------------------------------- riscos/bitmap.h | 24 -- riscos/configure.c | 3 - riscos/configure.h | 66 +++--- riscos/configure/con_memory.c | 145 ------------ riscos/configure/configure.h | 1 - riscos/gui.c | 11 +- 8 files changed, 38 insertions(+), 741 deletions(-) delete mode 100644 riscos/configure/con_memory.c (limited to 'riscos') diff --git a/riscos/Makefile.target b/riscos/Makefile.target index b32590bfa..3d64e24f9 100644 --- a/riscos/Makefile.target +++ b/riscos/Makefile.target @@ -83,7 +83,7 @@ S_RISCOS := 401login.c assert.c bitmap.c buffer.c cookies.c configure.c \ throbber.c url_bar.c) \ $(addprefix configure/,con_cache.c con_connect.c con_content.c \ con_fonts.c con_home.c con_image.c con_inter.c con_language.c \ - con_memory.c con_secure.c con_theme.c) + con_secure.c con_theme.c) S_RISCOS := $(addprefix riscos/,$(S_RISCOS)) TPL_RISCOS := de en fr nl # TODO: It'd be nice to auto-detect these TPL_RISCOS := $(addprefix riscos/templates/,$(TPL_RISCOS)) diff --git a/riscos/bitmap.c b/riscos/bitmap.c index 0f54003a9..60b0345d0 100644 --- a/riscos/bitmap.c +++ b/riscos/bitmap.c @@ -50,222 +50,9 @@ /** Colour in the overlay sprite that allows the bitmap to show through */ #define OVERLAY_INDEX 0xfe -#define MAINTENANCE_THRESHOLD 32 - /** Size of buffer used when constructing mask data to be saved */ #define SAVE_CHUNK_SIZE 4096 -/** The head of the bitmap list -*/ -struct bitmap *bitmap_head = NULL; - -/** Whether maintenance of the pool states is needed -*/ -bool bitmap_maintenance = false; - -/** Whether maintenance of the pool is high priority -*/ -bool bitmap_maintenance_priority = false; - -/** Maximum amount of memory for direct images -*/ -unsigned int bitmap_direct_size; - -/** Current amount of memory for direct images -*/ -unsigned int bitmap_direct_used = 0; - -/** Total size of compressed area -*/ -unsigned int bitmap_compressed_size; - -/** Total size of compressed area -*/ -unsigned int bitmap_compressed_used = 0; - -/** Compressed data header -*/ -struct bitmap_compressed_header { - int width; - int height; - char name[12]; - unsigned int flags; - unsigned int input_size; -}; - -char bitmap_unixname[256]; -char bitmap_filename[256]; - - - -static void bitmap_delete_file(struct bitmap *bitmap) -{ - assert(bitmap->filename[0]); - filename_release(bitmap->filename); - bitmap->filename[0] = 0; -} - - -static void bitmap_load_file(struct bitmap *bitmap) -{ - int len; - fileswitch_object_type obj_type; - os_error *error; - char *r; - struct bitmap_compressed_header *bitmap_compressed; - osspriteop_header *bitmap_direct; - int *data; - - assert(bitmap->filename); - - sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX, - bitmap->filename); - r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX, - bitmap_filename, 256, 0); - if (r == 0) { - LOG(("__riscosify failed")); - return; - } - error = xosfile_read_stamped_no_path(bitmap_filename, - &obj_type, 0, 0, &len, 0, 0); - if ((error) || (obj_type != fileswitch_IS_FILE)) - return; - - bitmap->compressed = malloc(len); - if (!bitmap->compressed) - return; - - error = xosfile_load_stamped_no_path(bitmap_filename, - (byte *) bitmap->compressed, 0, 0, 0, 0, 0); - if (error) { - free(bitmap->compressed); - bitmap->compressed = NULL; - return; - } - - data = (void *) bitmap->compressed; - - LOG(("Loaded file from disk")); - /* Sanity check the file we've just loaded: - * If it's an uncompressed buffer, then it's a raw sprite area, - * including the total size word at the start. Therefore, we check - * that: - * a) The declared total area size == file length - * b) The offset to the first free word == file length - * c) There is only 1 sprite in the area - * d) The name of the sprite in the area is "bitmap" - * - * If it's a compressed buffer, then we check that: - * a) The declared input size + header size == file length - * b) The name of the buffer is "bitmap" - * - * If it's neither of these, we fail. - */ - if (*data == len && *(data + 3) == len && *(data + 1) == 1 && - strncmp(bitmap->compressed + 20, "bitmap", 6) == 0) { - bitmap->sprite_area = (void *) bitmap->compressed; - bitmap->compressed = NULL; - bitmap_direct = (osspriteop_header *)(bitmap->sprite_area + 1); - bitmap->width = bitmap_direct->width + 1; - bitmap->height = bitmap_direct->height + 1; - bitmap_direct_used += 16 + 44 + - bitmap->width * bitmap->height * 4; - } else if ((int) (*(data + 6) + - sizeof(struct bitmap_compressed_header)) == len && - strncmp(bitmap->compressed + 8, "bitmap", 6) == 0) { - bitmap_compressed = (void *) bitmap->compressed; - bitmap_compressed_used -= bitmap_compressed->input_size + - sizeof(struct bitmap_compressed_header); - bitmap->width = bitmap_compressed->width; - bitmap->height = bitmap_compressed->height; - } else { - free(bitmap->compressed); - bitmap->compressed = NULL; - return; - } - if (bitmap->state & BITMAP_MODIFIED) - bitmap_delete_file(bitmap); -} - - -static void bitmap_save_file(struct bitmap *bitmap) -{ - unsigned int area_size; - const char *filename; - char *r; - os_error *error; - struct bitmap_compressed_header *header; - - assert(bitmap); - - if (!bitmap->compressed && !bitmap->sprite_area) { - LOG(("bitmap has no data")); - return; - } - - /* unmodified bitmaps will still have their file available */ - if ((!(bitmap->state & BITMAP_MODIFIED)) && bitmap->filename[0]) { - if (bitmap->sprite_area) - free(bitmap->sprite_area); - bitmap->sprite_area = NULL; - if (bitmap->compressed) - free(bitmap->compressed); - bitmap->compressed = NULL; - return; - } - - /* dump the data (compressed or otherwise) to disk */ - filename = filename_request(); - if (!filename) { - LOG(("filename_request failed")); - return; - } - - strcpy(bitmap->filename, filename); - sprintf(bitmap_unixname, "%s/%s", TEMP_FILENAME_PREFIX, - bitmap->filename); - r = __riscosify(bitmap_unixname, 0, __RISCOSIFY_NO_SUFFIX, - bitmap_filename, 256, 0); - if (r == 0) { - LOG(("__riscosify failed")); - return; - } - if (bitmap->compressed) { - header = (void *) bitmap->compressed; - area_size = header->input_size + - sizeof(struct bitmap_compressed_header); - error = xosfile_save_stamped(bitmap_filename, 0xffd, - (byte *) bitmap->compressed, - (byte *) bitmap->compressed + area_size); - } else { - area_size = bitmap->width * bitmap->height * 4 + - sizeof(osspriteop_header) + - sizeof(osspriteop_area); - error = xosfile_save_stamped(bitmap_filename, 0xffd, - (byte *) bitmap->sprite_area, - ((byte *) bitmap->sprite_area) + area_size); - } - - if (error) { - LOG(("xosfile_save_stamped: 0x%x: %s", - error->errnum, error->errmess)); - bitmap->filename[0] = 0; - } else { - if (bitmap->sprite_area) { - bitmap_direct_used -= area_size; - free(bitmap->sprite_area); - } - bitmap->sprite_area = NULL; - if (bitmap->compressed) { - bitmap_compressed_used -= area_size; - free(bitmap->compressed); - } - bitmap->compressed = NULL; - bitmap->state &= ~BITMAP_MODIFIED; - LOG(("Saved file to disk")); - } -} - /** * Initialise a bitmaps sprite area. @@ -291,7 +78,6 @@ static bool bitmap_initialise(struct bitmap *bitmap) if (!bitmap->sprite_area) return false; bitmap->state |= BITMAP_READY; - bitmap_direct_used += area_size; /* area control block */ sprite_area = bitmap->sprite_area; @@ -312,177 +98,10 @@ static bool bitmap_initialise(struct bitmap *bitmap) sprite->image = sprite->mask = 44; sprite->mode = tinct_SPRITE_MODE; - bitmap_maintenance = true; - bitmap_maintenance_priority |= - (bitmap_direct_used > bitmap_direct_size * 0.9); return true; } -static void bitmap_decompress(struct bitmap *bitmap) -{ - unsigned int area_size; - _kernel_oserror *error; - int output_size; - struct bitmap_compressed_header *header; - - assert(bitmap->compressed); - - /* ensure the width/height is correct */ - header = (void *)bitmap->compressed; - if ((header->width != bitmap->width) || - (header->height != bitmap->height)) { - LOG(("Warning: Mismatch between bitmap and compressed sizes")); - return; - } - - /* create the image memory/header to decompress to */ - if (!bitmap_initialise(bitmap)) - return; - - /* decompress the data */ - output_size = bitmap->width * bitmap->height * 4 + - sizeof(struct osspriteop_header); - error = _swix(Tinct_Decompress, _IN(0) | _IN(2) | _IN(3) | _IN(7), - bitmap->compressed, - (char *)(bitmap->sprite_area + 1), - output_size, - 0); - if (error) { - LOG(("Decompression error")); - free(bitmap->sprite_area); - bitmap->sprite_area = NULL; - } else { - LOG(("Decompressed")); - area_size = header->input_size + - sizeof(struct bitmap_compressed_header); - bitmap_compressed_used -= area_size; - free(bitmap->compressed); - bitmap->compressed = NULL; - area_size = 16 + 44 + bitmap->width * bitmap->height * 4; - bitmap_direct_used += area_size; - } -} - - -static void bitmap_compress(struct bitmap *bitmap) -{ - unsigned int area_size; - _kernel_oserror *error; - char *output; - unsigned int output_size, new_size; - unsigned int flags = 0; - float calc; - - /* get the maximum output size (33/32 * size) */ - output_size = ((bitmap->width * bitmap->height * 4 * 33) >> 5) + - sizeof(struct bitmap_compressed_header); - output = malloc(output_size); - if (!output) - return; - - /* compress the data */ - if (bitmap->state & BITMAP_OPAQUE) - flags |= tinct_OPAQUE_IMAGE; - error = _swix(Tinct_Compress, _IN(0) | _IN(2) | _IN(7) | _OUT(0), - (char *)(bitmap->sprite_area + 1), - output, - flags, - &new_size); - if (error) { - LOG(("Compression error")); - free(output); - } else { - bitmap->compressed = realloc(output, new_size); - if (!bitmap->compressed) { - free(output); - } else { - bitmap_compressed_used += new_size; - if (bitmap->sprite_area) { - area_size = 16 + 44 + bitmap->width * - bitmap->height * 4; - bitmap_direct_used -= area_size; - free(bitmap->sprite_area); - } - bitmap->sprite_area = NULL; - calc = (100 / (float)output_size) * new_size; - LOG(("Compression: %i->%i, %.3f%%", - output_size, new_size, calc)); - } - } -} - - -/** - * Initialise the bitmap memory pool. - */ - -void bitmap_initialise_memory(void) -{ - int available_memory, direct_size, compressed_size; - int free_slot; - os_error *error; - - /* calculate how much memory is currently free - (Note that the free_slot returned by wimp_slot_size - includes the next_slot; the value displayed by the - TaskManager has been adjusted to make it more logical - for the user). - */ - error = xwimp_slot_size(-1, -1, NULL, NULL, &free_slot); - if (error) { - LOG(("xwimp_slot_size: 0x%x: %s", - error->errnum, error->errmess)); - warn_user("WimpError", error->errmess); - return; - } - available_memory = free_slot; - - /* calculate our memory block sizes */ - if (nsoption_int(image_memory_direct) == -1) { - /* claim 25% of free memory - min 256KB, max 32768KB */ - direct_size = available_memory / 4; - if (direct_size < (256 << 10)) - direct_size = (256 << 10); - if (direct_size > (32768 << 10)) - direct_size = (32768 << 10); - } else { - direct_size = (nsoption_int(image_memory_direct) << 10); - } - if (nsoption_int(image_memory_compressed) == -1) { - /* claim 10% of free memory - min 256KB, max 4192KB */ - compressed_size = available_memory / 10; - if (compressed_size < (256 << 10)) - compressed_size = 0; - if (compressed_size > (4192 << 10)) - compressed_size = (4192 << 10); - } else { - compressed_size = (nsoption_int(image_memory_compressed) << 10); - } - - /* set our values. No fixed buffers here, ho hum. */ - bitmap_direct_size = direct_size; - bitmap_compressed_size = compressed_size; - bitmap_maintenance = bitmap_maintenance_priority = true; -} - - -/** - * Prepare for the end of a session. - */ - -void bitmap_quit(void) -{ - struct bitmap *bitmap; - - for (bitmap = bitmap_head; bitmap; bitmap = bitmap->next) - if ((bitmap->state & BITMAP_PERSISTENT) && - ((bitmap->state & BITMAP_MODIFIED) || - (bitmap->filename[0] == '\0'))) - bitmap_save_file(bitmap); -} - - /** * Create a bitmap. * @@ -506,12 +125,6 @@ void *bitmap_create(int width, int height, unsigned int state) bitmap->height = height; bitmap->state = state; - /* link into our list of bitmaps at the head */ - if (bitmap_head) { - bitmap->next = bitmap_head; - bitmap_head->previous = bitmap; - } - bitmap_head = bitmap; return bitmap; } @@ -700,38 +313,13 @@ unsigned char *bitmap_get_buffer(void *vbitmap) struct bitmap *bitmap = (struct bitmap *) vbitmap; assert(bitmap); - /* move to the head of the list */ - if (bitmap_head != bitmap) { - if (bitmap->previous) - bitmap->previous->next = bitmap->next; - if (bitmap->next) - bitmap->next->previous = bitmap->previous; - bitmap->next = bitmap_head; - bitmap_head->previous = bitmap; - bitmap->previous = NULL; - bitmap_head = bitmap; - } - /* dynamically create the buffer */ if (!(bitmap->state & BITMAP_READY)) { if (!bitmap_initialise(bitmap)) return NULL; } - /* image is already decompressed, no change to image states */ - if (bitmap->sprite_area) - return ((unsigned char *) (bitmap->sprite_area)) + 16 + 44; - - /* load and/or decompress the image */ - if (bitmap->filename[0]) - bitmap_load_file(bitmap); - if (bitmap->compressed) - bitmap_decompress(bitmap); - - bitmap_maintenance = true; - bitmap_maintenance_priority |= - (bitmap_direct_used > bitmap_direct_size * 0.9); - + /* image data area should exist */ if (bitmap->sprite_area) return ((unsigned char *) (bitmap->sprite_area)) + 16 + 44; @@ -762,34 +350,14 @@ size_t bitmap_get_rowstride(void *vbitmap) void bitmap_destroy(void *vbitmap) { struct bitmap *bitmap = (struct bitmap *) vbitmap; - struct bitmap_compressed_header *header; - unsigned int area_size; assert(bitmap); - /* delink from list */ - bitmap_maintenance = true; - if (bitmap_head == bitmap) - bitmap_head = bitmap->next; - if (bitmap->previous) - bitmap->previous->next = bitmap->next; - if (bitmap->next) - bitmap->next->previous = bitmap->previous; - /* destroy bitmap */ if (bitmap->sprite_area) { - area_size = 16 + 44 + bitmap->width * bitmap->height * 4; - bitmap_direct_used -= area_size; free(bitmap->sprite_area); } - if (bitmap->compressed) { - header = (void *) bitmap->compressed; - bitmap_compressed_used -= header->input_size + - sizeof(struct bitmap_compressed_header); - free(bitmap->compressed); - } - if (bitmap->filename[0]) - bitmap_delete_file(bitmap); + free(bitmap); } @@ -978,97 +546,6 @@ void bitmap_modified(void *vbitmap) { } -/** - * Performs routine maintenance. - */ -void bitmap_maintain(void) -{ - unsigned int memory = 0; - unsigned int compressed_memory = 0; - struct bitmap *bitmap = bitmap_head; - struct bitmap_compressed_header *header; - unsigned int maintain_direct_size; - - LOG(("Performing maintenance.")); - - /* under heavy loads allow an extra 30% to work with */ - maintain_direct_size = bitmap_direct_size; - if (!bitmap_maintenance_priority) - maintain_direct_size = maintain_direct_size * 0.7; - - if ((!bitmap) || ((bitmap_direct_used < maintain_direct_size) && - (bitmap_compressed_used < bitmap_compressed_size))) { - bitmap_maintenance = bitmap_maintenance_priority; - bitmap_maintenance_priority = false; - return; - } - - /* we don't change the first bitmap_MEMORY entries as they - * will automatically be loaded/decompressed from whatever state - * they are in when neeeded. */ - for (; bitmap && (memory < maintain_direct_size); - bitmap = bitmap->next) { - if (bitmap->sprite_area) - memory += bitmap->width * bitmap->height * 4; - else if ((bitmap->compressed) && - (!bitmap_maintenance_priority)) { - header = (void *) bitmap->compressed; - compressed_memory += header->input_size + - sizeof(struct bitmap_compressed_header); - } - } - - if (!bitmap) { - bitmap_maintenance = bitmap_maintenance_priority; - bitmap_maintenance_priority = false; - return; - } - - /* under heavy loads, we ignore compression */ - if (!bitmap_maintenance_priority) { - /* for the next section, up until bitmap_COMPRESSED we - * forcibly compress the data if it's currently held directly - * in memory */ - for (; bitmap && (compressed_memory < bitmap_compressed_size); - bitmap = bitmap->next) { - if (bitmap->sprite_area) { - if ((bitmap->width * bitmap->height) <= - (512 * 512)) - bitmap_compress(bitmap); - else - bitmap_save_file(bitmap); - return; - } - if (bitmap->compressed) { - header = (void *) bitmap->compressed; - compressed_memory += header->input_size + - sizeof(struct bitmap_compressed_header); - } - } - if (!bitmap) { - bitmap_maintenance = false; - return; - } - } - - /* for the remaining entries we dump to disk */ - for (; bitmap; bitmap = bitmap->next) { - if ((bitmap->sprite_area) || (bitmap->compressed)) { - if (bitmap_maintenance_priority) { - if (bitmap->sprite_area) - bitmap_save_file(bitmap); - - } else { - bitmap_save_file(bitmap); - return; - } - } - } - bitmap_maintenance = bitmap_maintenance_priority; - bitmap_maintenance_priority = false; -} - - int bitmap_get_width(void *vbitmap) { struct bitmap *bitmap = (struct bitmap *) vbitmap; diff --git a/riscos/bitmap.h b/riscos/bitmap.h index 1253830cc..43a00a53c 100644 --- a/riscos/bitmap.h +++ b/riscos/bitmap.h @@ -34,33 +34,9 @@ struct bitmap { void *private_word; osspriteop_area *sprite_area; /** Uncompressed data, or NULL */ - char *compressed; /** Compressed data, or NULL */ - char filename[12]; /** Data filename, or '/0' */ - - struct bitmap *previous; /** Previous bitmap */ - struct bitmap *next; /** Next bitmap */ }; void bitmap_overlay_sprite(struct bitmap *bitmap, const osspriteop_header *s); -void bitmap_initialise_memory(void); -void bitmap_quit(void); -void bitmap_maintain(void); - -/** Whether maintenance of the pool states is needed -*/ -extern bool bitmap_maintenance; - -/** Whether maintenance of the pool is high priority -*/ -extern bool bitmap_maintenance_priority; - -/** Maximum amount of memory for direct images -*/ -extern unsigned int bitmap_direct_size; - -/** Total size of compressed area -*/ -extern unsigned int bitmap_compressed_size; #endif diff --git a/riscos/configure.c b/riscos/configure.c index 99c69e126..0f5ee322b 100644 --- a/riscos/configure.c +++ b/riscos/configure.c @@ -108,9 +108,6 @@ void ro_gui_configure_initialise(void) ro_gui_configure_register("con_lang", ro_gui_options_language_initialise, ro_gui_wimp_event_finalise); - ro_gui_configure_register("con_memory", - ro_gui_options_memory_initialise, - ro_gui_wimp_event_finalise); ro_gui_configure_register("con_theme", ro_gui_options_theme_initialise, ro_gui_options_theme_finalise); diff --git a/riscos/configure.h b/riscos/configure.h index da29d1c25..c190a6d0c 100644 --- a/riscos/configure.h +++ b/riscos/configure.h @@ -1,34 +1,34 @@ -/* - * Copyright 2005 Richard Wilson - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** \file - * RISC OS option setting (interface). - */ - - -#ifndef _NETSURF_RISCOS_CONFIGURE_H_ -#define _NETSURF_RISCOS_CONFIGURE_H_ - -#include -#include "oslib/os.h" -#include "oslib/wimp.h" - -void ro_gui_configure_initialise(void); -void ro_gui_configure_show(void); +/* + * Copyright 2005 Richard Wilson + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ -#endif +/** \file + * RISC OS option setting (interface). + */ + + +#ifndef _NETSURF_RISCOS_CONFIGURE_H_ +#define _NETSURF_RISCOS_CONFIGURE_H_ + +#include +#include "oslib/os.h" +#include "oslib/wimp.h" + +void ro_gui_configure_initialise(void); +void ro_gui_configure_show(void); + +#endif diff --git a/riscos/configure/con_memory.c b/riscos/configure/con_memory.c deleted file mode 100644 index 273684959..000000000 --- a/riscos/configure/con_memory.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2006 Richard Wilson - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include "utils/nsoption.h" -#include "riscos/bitmap.h" -#include "riscos/wimp.h" -#include "riscos/wimp_event.h" -#include "riscos/dialog.h" -#include "riscos/configure/configure.h" - - -#define MEMORY_DIRECT_FIELD 3 -#define MEMORY_DIRECT_DEC 4 -#define MEMORY_DIRECT_INC 5 -#define MEMORY_DIRECT_TEXT 6 -#define MEMORY_DIRECT_AUTO 7 -#define MEMORY_COMPRESSED_FIELD 9 -#define MEMORY_COMPRESSED_DEC 10 -#define MEMORY_COMPRESSED_INC 11 -#define MEMORY_COMPRESSED_TEXT 12 -#define MEMORY_COMPRESSED_AUTO 13 -#define MEMORY_DEFAULT_BUTTON 14 -#define MEMORY_CANCEL_BUTTON 15 -#define MEMORY_OK_BUTTON 16 - -static bool ro_gui_options_memory_click(wimp_pointer *pointer); -static bool ro_gui_options_memory_ok(wimp_w w); -static void ro_gui_options_update_shading(wimp_w w); - -bool ro_gui_options_memory_initialise(wimp_w w) -{ - /* set the current values */ - ro_gui_set_icon_decimal(w, MEMORY_DIRECT_FIELD, - (bitmap_direct_size * 10) >> 20, 1); - ro_gui_set_icon_decimal(w, MEMORY_COMPRESSED_FIELD, - (bitmap_compressed_size * 10) >> 20, 1); - ro_gui_set_icon_selected_state(w, MEMORY_DIRECT_AUTO, - (nsoption_int(image_memory_direct) == -1)); - ro_gui_set_icon_selected_state(w, MEMORY_COMPRESSED_AUTO, - (nsoption_int(image_memory_compressed) == -1)); - ro_gui_options_update_shading(w); - - /* register icons */ - ro_gui_wimp_event_register_checkbox(w, MEMORY_DIRECT_AUTO); - ro_gui_wimp_event_register_checkbox(w, MEMORY_COMPRESSED_AUTO); - ro_gui_wimp_event_register_text_field(w, MEMORY_DIRECT_TEXT); - ro_gui_wimp_event_register_text_field(w, MEMORY_COMPRESSED_TEXT); - ro_gui_wimp_event_register_numeric_field(w, MEMORY_DIRECT_FIELD, - MEMORY_DIRECT_INC, MEMORY_DIRECT_DEC, - 10, 5120, 10, 1); - ro_gui_wimp_event_register_numeric_field(w, MEMORY_COMPRESSED_FIELD, - MEMORY_COMPRESSED_INC, MEMORY_COMPRESSED_DEC, - 10, 5120, 10, 1); - ro_gui_wimp_event_register_mouse_click(w, - ro_gui_options_memory_click); - ro_gui_wimp_event_register_cancel(w, MEMORY_CANCEL_BUTTON); - ro_gui_wimp_event_register_ok(w, MEMORY_OK_BUTTON, - ro_gui_options_memory_ok); - ro_gui_wimp_event_set_help_prefix(w, "HelpMemoryConfig"); - ro_gui_wimp_event_memorise(w); - return true; - -} - -bool ro_gui_options_memory_click(wimp_pointer *pointer) -{ - switch (pointer->i) { - case MEMORY_DIRECT_AUTO: - ro_gui_options_update_shading(pointer->w); - return false; - case MEMORY_COMPRESSED_AUTO: - ro_gui_options_update_shading(pointer->w); - return false; - case MEMORY_DEFAULT_BUTTON: - ro_gui_set_icon_decimal(pointer->w, MEMORY_DIRECT_FIELD, - (bitmap_direct_size * 10) >> 20, 1); - ro_gui_set_icon_decimal(pointer->w, MEMORY_COMPRESSED_FIELD, - (bitmap_compressed_size * 10) >> 20, 1); - ro_gui_set_icon_selected_state(pointer->w, - MEMORY_DIRECT_AUTO, true); - ro_gui_set_icon_selected_state(pointer->w, - MEMORY_COMPRESSED_AUTO, true); - ro_gui_options_update_shading(pointer->w); - return true; - } - return false; -} - -void ro_gui_options_update_shading(wimp_w w) -{ - bool shaded; - - shaded = ro_gui_get_icon_selected_state(w, MEMORY_DIRECT_AUTO); - ro_gui_set_icon_shaded_state(w, MEMORY_DIRECT_FIELD, shaded); - ro_gui_set_icon_shaded_state(w, MEMORY_DIRECT_INC, shaded); - ro_gui_set_icon_shaded_state(w, MEMORY_DIRECT_DEC, shaded); - ro_gui_set_icon_shaded_state(w, MEMORY_DIRECT_TEXT, shaded); - shaded = ro_gui_get_icon_selected_state(w, MEMORY_COMPRESSED_AUTO); - ro_gui_set_icon_shaded_state(w, MEMORY_COMPRESSED_FIELD, shaded); - ro_gui_set_icon_shaded_state(w, MEMORY_COMPRESSED_INC, shaded); - ro_gui_set_icon_shaded_state(w, MEMORY_COMPRESSED_DEC, shaded); - ro_gui_set_icon_shaded_state(w, MEMORY_COMPRESSED_TEXT, shaded); -} - -bool ro_gui_options_memory_ok(wimp_w w) -{ - /* set the option values */ - if (ro_gui_get_icon_selected_state(w, MEMORY_DIRECT_AUTO)) - nsoption_set_int(image_memory_direct, -1); - else - nsoption_set_int(image_memory_direct, - (((ro_gui_get_icon_decimal(w, MEMORY_DIRECT_FIELD, 1) - << 10) + 1023) / 10)); - if (ro_gui_get_icon_selected_state(w, MEMORY_COMPRESSED_AUTO)) - nsoption_set_int(image_memory_compressed, -1); - else - nsoption_set_int(image_memory_compressed, - (((ro_gui_get_icon_decimal(w, MEMORY_COMPRESSED_FIELD, 1) - << 10) + 1023) / 10)); - /* update the memory usage */ - bitmap_initialise_memory(); - ro_gui_set_icon_decimal(w, MEMORY_DIRECT_FIELD, - (bitmap_direct_size * 10) >> 20, 1); - ro_gui_set_icon_decimal(w, MEMORY_COMPRESSED_FIELD, - (bitmap_compressed_size * 10) >> 20, 1); - /* save the options */ - ro_gui_save_options(); - return true; -} diff --git a/riscos/configure/configure.h b/riscos/configure/configure.h index 5350be8f4..e5cdb392e 100644 --- a/riscos/configure/configure.h +++ b/riscos/configure/configure.h @@ -36,7 +36,6 @@ bool ro_gui_options_image_initialise(wimp_w w); void ro_gui_options_image_finalise(wimp_w w); bool ro_gui_options_interface_initialise(wimp_w w); bool ro_gui_options_language_initialise(wimp_w w); -bool ro_gui_options_memory_initialise(wimp_w w); bool ro_gui_options_security_initialise(wimp_w w); bool ro_gui_options_theme_initialise(wimp_w w); void ro_gui_options_theme_finalise(wimp_w w); diff --git a/riscos/gui.c b/riscos/gui.c index fc857f20c..9b3bf4a92 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -483,9 +483,6 @@ static void gui_init(int argc, char** argv) /* Initialise save complete functionality */ save_complete_init(); - /* Initialise bitmap memory pool */ - bitmap_initialise_memory(); - /* Load in visited URLs and Cookies */ urldb_load(nsoption_charp(url_path)); urldb_load_cookies(nsoption_charp(cookie_file)); @@ -921,7 +918,6 @@ int main(int argc, char** argv) void gui_quit(void) { - bitmap_quit(); urldb_save_cookies(nsoption_charp(cookie_jar)); urldb_save(nsoption_charp(url_save)); ro_gui_window_quit(); @@ -1037,8 +1033,8 @@ void gui_poll(bool active) track_poll_offset = ro_mouse_poll_interval(); if (active) { event = wimp_poll(mask, &block, 0); - } else if (sched_active || (track_poll_offset > 0) || browser_reformat_pending || - bitmap_maintenance) { + } else if (sched_active || (track_poll_offset > 0) || + browser_reformat_pending) { os_t t = os_read_monotonic_time(); if (track_poll_offset > 0) @@ -1070,9 +1066,6 @@ void gui_poll(bool active) if (browser_reformat_pending && event == wimp_NULL_REASON_CODE) ro_gui_window_process_reformats(); - else if (bitmap_maintenance_priority || - (bitmap_maintenance && event == wimp_NULL_REASON_CODE)) - bitmap_maintain(); } -- cgit v1.2.3