summaryrefslogtreecommitdiff
path: root/riscos/sprite.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-11-06 19:34:24 +0000
committerJames Bursa <james@netsurf-browser.org>2004-11-06 19:34:24 +0000
commit86e789856c803e6a50dc9e729d72d8bc5fbe9192 (patch)
treeae68db0f6bba3f056ca7b95f42564c81589369c5 /riscos/sprite.c
parente221793b4236ec33e5b1808c968c5a714c0cec36 (diff)
downloadnetsurf-86e789856c803e6a50dc9e729d72d8bc5fbe9192.tar.gz
netsurf-86e789856c803e6a50dc9e729d72d8bc5fbe9192.tar.bz2
[project @ 2004-11-06 19:34:24 by bursa]
Fix RISC OS sprite rendering. Document files. svn path=/import/netsurf/; revision=1348
Diffstat (limited to 'riscos/sprite.c')
-rw-r--r--riscos/sprite.c59
1 files changed, 51 insertions, 8 deletions
diff --git a/riscos/sprite.c b/riscos/sprite.c
index 0174cc1bd..a68cd57ce 100644
--- a/riscos/sprite.c
+++ b/riscos/sprite.c
@@ -5,13 +5,22 @@
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
*/
-#include <assert.h>
+/** \file
+ * Content for image/x-riscos-sprite (RISC OS implementation).
+ *
+ * No conversion is necessary: we can render RISC OS sprites directly under
+ * RISC OS.
+ *
+ * Unfortunately we have to make a copy of the bitmap data, because sprite areas
+ * need a length word at the start.
+ */
+
#include <string.h>
#include <stdlib.h>
-#include "oslib/colourtrans.h"
#include "oslib/osspriteop.h"
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
+#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/image.h"
#include "netsurf/riscos/sprite.h"
#include "netsurf/utils/log.h"
@@ -20,6 +29,13 @@
#ifdef WITH_SPRITE
+
+/**
+ * Create a new CONTENT_SPRITE.
+ *
+ * A new empty sprite area is allocated.
+ */
+
bool sprite_create(struct content *c, const char *params[])
{
union content_msg_data msg_data;
@@ -36,6 +52,12 @@ bool sprite_create(struct content *c, const char *params[])
}
+/**
+ * Process data for a CONTENT_SPRITE.
+ *
+ * The data is just copied into the sprite area.
+ */
+
bool sprite_process_data(struct content *c, char *data, unsigned int size)
{
char *sprite_data;
@@ -58,6 +80,12 @@ bool sprite_process_data(struct content *c, char *data, unsigned int size)
}
+/**
+ * Convert a CONTENT_SPRITE for display.
+ *
+ * No conversion is necessary. We merely read the sprite dimensions.
+ */
+
bool sprite_convert(struct content *c, int width, int height)
{
os_error *error;
@@ -70,7 +98,7 @@ bool sprite_convert(struct content *c, int width, int height)
error = xosspriteop_read_sprite_info(osspriteop_PTR,
area,
- (osspriteop_id)((char*)(c->data.sprite.data) + area->first),
+ (osspriteop_id) ((char *) area + area->first),
&w, &h, NULL, NULL);
if (error) {
LOG(("xosspriteop_read_sprite_info: 0x%x: %s",
@@ -85,12 +113,16 @@ bool sprite_convert(struct content *c, int width, int height)
c->title = malloc(100);
if (c->title)
snprintf(c->title, 100, messages_get("SpriteTitle"), c->width,
- c->height, c->data.sprite.length);
+ c->height, c->data.sprite.length);
c->status = CONTENT_STATUS_DONE;
return true;
}
+/**
+ * Destroy a CONTENT_SPRITE and free all resources it owns.
+ */
+
void sprite_destroy(struct content *c)
{
free(c->data.sprite.data);
@@ -98,13 +130,24 @@ void sprite_destroy(struct content *c)
}
+/**
+ * Redraw a CONTENT_SPRITE.
+ */
+
bool sprite_redraw(struct content *c, int x, int y,
int width, int height,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
- float scale, unsigned long background_colour)
+ float scale, colour background_colour)
{
- return image_redraw(c->data.sprite.data, x, y, width, height,
- c->width * 2, c->height * 2, background_colour,
- false, false, false, IMAGE_PLOT_OS);
+ return image_redraw(c->data.sprite.data,
+ ro_plot_origin_x + x * 2,
+ ro_plot_origin_y - y * 2,
+ width, height,
+ c->width,
+ c->height,
+ background_colour,
+ false, false, false,
+ IMAGE_PLOT_OS);
}
+
#endif