summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--riscos/draw.c111
-rw-r--r--riscos/draw.h28
-rw-r--r--riscos/sprite.c108
-rw-r--r--riscos/sprite.h30
4 files changed, 277 insertions, 0 deletions
diff --git a/riscos/draw.c b/riscos/draw.c
new file mode 100644
index 000000000..b8a07e7f4
--- /dev/null
+++ b/riscos/draw.c
@@ -0,0 +1,111 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include "netsurf/content/content.h"
+#include "netsurf/riscos/draw.h"
+#include "netsurf/utils/utils.h"
+#include "netsurf/utils/log.h"
+#include "oslib/drawfile.h"
+
+void draw_create(struct content *c)
+{
+ c->data.draw.data = xcalloc(0, 1);
+ c->data.draw.length = 0;
+}
+
+
+void draw_process_data(struct content *c, char *data, unsigned long size)
+{
+ c->data.draw.data = xrealloc(c->data.draw.data, c->data.draw.length + size);
+ memcpy(c->data.draw.data + c->data.draw.length, data, size);
+ c->data.draw.length += size;
+ c->size += size;
+}
+
+
+int draw_convert(struct content *c, unsigned int width, unsigned int height)
+{
+ os_error *error;
+ os_trfm *matrix = xcalloc(1, sizeof(os_trfm));
+ os_box *bbox = xcalloc(1, sizeof(os_box));
+
+ /* Full size image (1:1) */
+ matrix->entries[0][0] = 1 << 16;
+ matrix->entries[0][1] = 0;
+ matrix->entries[1][0] = 0;
+ matrix->entries[1][1] = 1 << 16;
+ matrix->entries[2][0] = 0;
+ matrix->entries[2][1] = 0;
+
+ /* BBox contents in Draw units (256*OS unit) */
+ error = xdrawfile_bbox(0, (drawfile_diagram*)(c->data.draw.data),
+ c->data.draw.length, matrix, bbox);
+
+ if (error) {
+ LOG(("error: %s", error->errmess));
+ xfree(matrix);
+ xfree(bbox);
+ return 1;
+ }
+
+ /* c->width & c->height stored as (OS units/2)
+ => divide by 512 to convert from draw units */
+ c->width = ((bbox->x1 - bbox->x0) / 512);
+ c->height = ((bbox->y1 - bbox->y0) / 512);
+ c->title = xcalloc(100, 1);
+ sprintf(c->title, "Draw image (%lux%lu, %lu bytes)", c->width,
+ c->height, c->data.draw.length);
+ c->status = CONTENT_STATUS_DONE;
+ xfree(matrix);
+ xfree(bbox);
+ return 0;
+}
+
+
+void draw_revive(struct content *c, unsigned int width, unsigned int height)
+{
+}
+
+
+void draw_reformat(struct content *c, unsigned int width, unsigned int height)
+{
+}
+
+
+void draw_destroy(struct content *c)
+{
+ xfree(c->data.draw.data);
+ xfree(c->title);
+}
+
+
+void draw_redraw(struct content *c, long x, long y,
+ unsigned long width, unsigned long height,
+ long clip_x0, long clip_y0, long clip_x1, long clip_y1)
+{
+ os_error *error;
+ unsigned int size;
+ os_box bbox;
+ os_trfm *matrix = xcalloc(1, sizeof(os_trfm));
+
+ /* Scaled image. Transform units (65536*OS units) */
+ matrix->entries[0][0] = ((width*65536) / (c->width*2));
+ matrix->entries[0][1] = 0;
+ matrix->entries[1][0] = 0;
+ matrix->entries[1][1] = ((height*65536) / (c->height*2));
+ /* Draw units. (x,y) = bottom left */
+ matrix->entries[2][0] = x * 256;
+ matrix->entries[2][1] = (y-height) * 256;
+
+ xdrawfile_render(0, (drawfile_diagram*)(c->data.draw.data),
+ c->data.draw.length, matrix, 0, 0);
+
+ xfree(matrix);
+}
diff --git a/riscos/draw.h b/riscos/draw.h
new file mode 100644
index 000000000..4ea73386d
--- /dev/null
+++ b/riscos/draw.h
@@ -0,0 +1,28 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
+ */
+
+#ifndef _NETSURF_RISCOS_DRAW_H_
+#define _NETSURF_RISCOS_DRAW_H_
+
+struct content;
+
+struct content_draw_data {
+ void* data;
+ unsigned long length;
+};
+
+void draw_init(void);
+void draw_create(struct content *c);
+void draw_process_data(struct content *c, char *data, unsigned long size);
+int draw_convert(struct content *c, unsigned int width, unsigned int height);
+void draw_revive(struct content *c, unsigned int width, unsigned int height);
+void draw_reformat(struct content *c, unsigned int width, unsigned int height);
+void draw_destroy(struct content *c);
+void draw_redraw(struct content *c, long x, long y,
+ unsigned long width, unsigned long height,
+ long clip_x0, long clip_y0, long clip_x1, long clip_y1);
+#endif
diff --git a/riscos/sprite.c b/riscos/sprite.c
new file mode 100644
index 000000000..50ec53b37
--- /dev/null
+++ b/riscos/sprite.c
@@ -0,0 +1,108 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include "netsurf/content/content.h"
+#include "netsurf/riscos/sprite.h"
+#include "netsurf/utils/utils.h"
+#include "netsurf/utils/log.h"
+#include "oslib/colourtrans.h"
+#include "oslib/osspriteop.h"
+
+void sprite_create(struct content *c)
+{
+ c->data.sprite.data = xcalloc(0, 1);
+ c->data.sprite.length = 0;
+}
+
+
+void sprite_process_data(struct content *c, char *data, unsigned long size)
+{
+ c->data.sprite.data = xrealloc(c->data.sprite.data, c->data.sprite.length + size);
+ memcpy(c->data.sprite.data + c->data.sprite.length, data, size);
+ c->data.sprite.length += size;
+ c->size += size;
+}
+
+
+int sprite_convert(struct content *c, unsigned int width, unsigned int height)
+{
+ os_error *error;
+ int w, h;
+
+ error = xosspriteop_read_sprite_info(osspriteop_USER_AREA,
+ (osspriteop_area*)(c->data.sprite.data-4),
+ (osspriteop_id)((osspriteop_area*)c->data.sprite.data + 1),
+ &w, &h, NULL, NULL);
+
+ if (error) {
+ LOG(("error: %s", error->errmess));
+ return 1;
+ }
+
+ c->width = w;
+ c->height = h;
+ c->title = xcalloc(100, 1);
+ sprintf(c->title, "Sprite image (%lux%lu, %lu bytes)", c->width,
+ c->height, c->data.sprite.length);
+ c->status = CONTENT_STATUS_DONE;
+ return 0;
+}
+
+
+void sprite_revive(struct content *c, unsigned int width, unsigned int height)
+{
+}
+
+
+void sprite_reformat(struct content *c, unsigned int width, unsigned int height)
+{
+}
+
+
+void sprite_destroy(struct content *c)
+{
+ xfree(c->data.sprite.data);
+ xfree(c->title);
+}
+
+
+void sprite_redraw(struct content *c, long x, long y,
+ unsigned long width, unsigned long height,
+ long clip_x0, long clip_y0, long clip_x1, long clip_y1)
+{
+ unsigned int size;
+ osspriteop_trans_tab *table;
+ os_factors factors;
+
+ xcolourtrans_generate_table_for_sprite(
+ (osspriteop_area*)(c->data.sprite.data-4),
+ (osspriteop_id) ((osspriteop_area*)c->data.sprite.data + 1),
+ colourtrans_CURRENT_MODE, colourtrans_CURRENT_PALETTE,
+ 0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
+ table = xcalloc(size, 1);
+ xcolourtrans_generate_table_for_sprite(
+ (osspriteop_area*)(c->data.sprite.data-4),
+ (osspriteop_id) ((osspriteop_area*)c->data.sprite.data + 1),
+ colourtrans_CURRENT_MODE, colourtrans_CURRENT_PALETTE,
+ table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
+
+ factors.xmul = width;
+ factors.ymul = height;
+ factors.xdiv = c->width * 2;
+ factors.ydiv = c->height * 2;
+
+ xosspriteop_put_sprite_scaled(osspriteop_USER_AREA,
+ (osspriteop_area*)(c->data.sprite.data-4),
+ (osspriteop_id) ((osspriteop_area*)c->data.sprite.data + 1),
+ x, y - height,
+ osspriteop_USE_MASK | osspriteop_USE_PALETTE, &factors, table);
+
+ xfree(table);
+}
diff --git a/riscos/sprite.h b/riscos/sprite.h
new file mode 100644
index 000000000..64cfc0888
--- /dev/null
+++ b/riscos/sprite.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
+ */
+
+#ifndef _NETSURF_RISCOS_SPRITE_H_
+#define _NETSURF_RISCOS_SPRITE_H_
+
+#include "oslib/osspriteop.h"
+
+struct content;
+
+struct content_sprite_data {
+ void* data;
+ unsigned long length;
+};
+
+void sprite_init(void);
+void sprite_create(struct content *c);
+void sprite_process_data(struct content *c, char *data, unsigned long size);
+int sprite_convert(struct content *c, unsigned int width, unsigned int height);
+void sprite_revive(struct content *c, unsigned int width, unsigned int height);
+void sprite_reformat(struct content *c, unsigned int width, unsigned int height);
+void sprite_destroy(struct content *c);
+void sprite_redraw(struct content *c, long x, long y,
+ unsigned long width, unsigned long height,
+ long clip_x0, long clip_y0, long clip_x1, long clip_y1);
+#endif