23#include <oslib/colourtrans.h>
25#include <oslib/osspriteop.h>
26#include <oslib/wimp.h>
27#include <oslib/wimpreadsysinfo.h>
38#define BUFFER_EXCLUSIVE_USER_REDRAW "Only support pure user redraw (faster)"
43#ifndef osspriteop_TYPEEXPANSION
44#define osspriteop_TYPEEXPANSION ((osspriteop_mode_word) 0xFu)
46#ifndef osspriteop_TYPE16BPP4K
47#define osspriteop_TYPE16BPP4K ((osspriteop_mode_word) 0x10u)
55static osspriteop_area *
buffer = NULL;
93#ifdef BUFFER_EXCLUSIVE_USER_REDRAW
94 osspriteop_header *header;
111 "Invalid clipping rectangle (%i, %i) to (%i,%i)",
124 if (sprite_size.y == 1)
127#ifdef BUFFER_EMULATE_32BPP
133 xos_read_mode_variable((os_mode)-1, os_MODEVAR_LOG2_BPP, &bpp, 0);
139 word_width = ((sprite_size.x << bpp) + 31) >> 5;
141 palette_size = ((1 << (1 << bpp)) << 3);
142 total_size =
sizeof(osspriteop_area) +
sizeof(osspriteop_header) +
143 (word_width * sprite_size.y * 4) + palette_size;
144 buffer = (osspriteop_area *)malloc(total_size);
146 NSLOG(netsurf, INFO,
"Failed to allocate memory");
150 buffer->size = total_size;
153#ifdef BUFFER_EMULATE_32BPP
156 if ((error = xwimpreadsysinfo_wimp_mode(&
mode)) != NULL) {
157 NSLOG(netsurf, INFO,
"Error reading mode '%s'",
165 if (
mode >= (os_mode)0x100) {
169 os_MODEVAR_MODE_FLAGS,
171 os_MODEVAR_XEIG_FACTOR,
172 os_MODEVAR_YEIG_FACTOR,
187 "Error reading mode properties '%s'",
193 switch (vals.ncolour) {
200 type = 1 + vals.log2bpp;
201 mode = (os_mode)((
type << osspriteop_TYPE_SHIFT) |
202 osspriteop_NEW_STYLE |
203 ((180 >> vals.yeig) << osspriteop_YRES_SHIFT) |
204 ((180 >> vals.xeig) << osspriteop_XRES_SHIFT));
210 osspriteop_NEW_STYLE |
214 (vals.flags & 0xFF00));
217 switch ((vals.flags & 0x3000) >> os_MODE_FLAG_DATA_FORMAT_SHIFT) {
218 case os_MODE_FLAG_DATA_FORMAT_RGB:
219 if (vals.flags & 0xC000) {
221 if (vals.flags & os_MODE_FLAG_FULL_PALETTE)
222 type = osspriteop_TYPE16BPP64K;
224 type = osspriteop_TYPE16BPP;
226 osspriteop_NEW_STYLE |
230 (vals.flags & 0xFF00));
233 if (vals.flags & os_MODE_FLAG_FULL_PALETTE)
234 type = osspriteop_TYPE16BPP64K;
236 type = osspriteop_TYPE16BPP;
237 mode = (os_mode)((
type << osspriteop_TYPE_SHIFT) |
238 osspriteop_NEW_STYLE |
239 ((180 >> vals.yeig) << osspriteop_YRES_SHIFT) |
240 ((180 >> vals.xeig) << osspriteop_XRES_SHIFT));
245 "Unhandled 16bpp format from flags %d",
253 switch ((vals.flags & 0x3000) >> os_MODE_FLAG_DATA_FORMAT_SHIFT) {
254 case os_MODE_FLAG_DATA_FORMAT_RGB:
255 if (vals.flags & 0xC000) {
257 type = osspriteop_TYPE32BPP;
259 osspriteop_NEW_STYLE |
263 (vals.flags & 0xFF00));
266 type = osspriteop_TYPE32BPP;
267 mode = (os_mode)((
type << osspriteop_TYPE_SHIFT) |
268 osspriteop_NEW_STYLE |
269 ((180 >> vals.yeig) << osspriteop_YRES_SHIFT) |
270 ((180 >> vals.xeig) << osspriteop_XRES_SHIFT));
275 "Unhandled 32bpp data format from flags %d",
282 NSLOG(netsurf, INFO,
"Unhandled NCOLOUR value %d",
290#ifdef BUFFER_EXCLUSIVE_USER_REDRAW
295 buffer->used = total_size;
296 header = (osspriteop_header *)(
buffer + 1);
297 header->size = total_size -
sizeof(osspriteop_area);
299 header->width = word_width - 1;
300 header->height = sprite_size.y - 1;
301 header->left_bit = 0;
302 header->right_bit = ((sprite_size.x << bpp) - 1) & 31;
303 header->image =
sizeof(osspriteop_header) + palette_size;
304 header->mask = header->image;
307 xcolourtrans_read_palette((osspriteop_area *)
mode,
308 (osspriteop_id)os_CURRENT_MODE,
309 (os_palette *)(header + 1), palette_size,
310 (colourtrans_palette_flags)
311 colourtrans_FLASHING_PALETTE, 0);
317 if ((error = xosspriteop_get_sprite_user_coords(osspriteop_NAME,
321 NSLOG(netsurf, INFO,
"Grab error '%s'", error->errmess);
328 if ((error = xosspriteop_read_save_area_size(osspriteop_PTR,
330 NSLOG(netsurf, INFO,
"Save area error '%s'", error->errmess);
334 if ((
save_area = malloc((
size_t)size)) == NULL) {
342 if ((error = xosspriteop_switch_output_to_sprite(osspriteop_PTR,
345 NSLOG(netsurf, INFO,
"Switching error '%s'", error->errmess);
361 NSLOG(netsurf, INFO,
"Invalid ECF origin: '%s'",
387 _swix(
Tinct_Plot, _IN(2) | _IN(3) | _IN(4) | _IN(7),
392 xosspriteop_put_sprite_user_coords(osspriteop_PTR,
399 os_set_ecf_origin(0, 0);
void ro_gui_buffer_close(void)
Closes any open buffer and flushes the contents to screen.
static osspriteop_save_area * save_area
The current save area.
void ro_gui_buffer_open(const wimp_draw *redraw)
Opens a buffer for writing to.
#define osspriteop_TYPE16BPP4K
static os_mode mode
The current sprite mode.
static os_box clipping
The current clip area.
static osspriteop_area * buffer
The buffer characteristics.
static char buffer_name[12]
static void ro_gui_buffer_free(void)
Releases any buffer memory depending on cache constraints.
#define osspriteop_TYPEEXPANSION
Absent from OSLib.
Screen buffering (interface).
#define NSLOG(catname, level, logmsg, args...)
Interface to utility string handling.
Tinct SWI numbers and flags for version 0.11.
#define tinct_SPRITE_MODE
#define Tinct_Plot
Plots a sprite at the specified coordinates with a constant 0xff value for the alpha channel,...
Option reading and saving interface.
#define nsoption_int(OPTION)
Get the value of an integer option.
void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode)
Converts the supplied os_coord from OS units to pixels.
General RISC OS WIMP/OS library functions (interface).
A collection of grubby utilities for working with OSLib's wimp API.
#define PTR_OS_VDU_VAR_LIST(l)