From 4d031f21cbc75bd47db0f52e1f9b2222444777b3 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 5 Apr 2010 21:58:38 +0000 Subject: [PATCH] Port to new content API svn path=/trunk/netsurf/; revision=10245 --- riscos/sprite.c | 36 ++++++++++++++++++++++++++---------- riscos/sprite.h | 3 ++- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/riscos/sprite.c b/riscos/sprite.c index 305a4f6f0..b60a42d5a 100644 --- a/riscos/sprite.c +++ b/riscos/sprite.c @@ -31,7 +31,7 @@ #include "oslib/osspriteop.h" #include "utils/config.h" #include "desktop/plotters.h" -#include "content/content.h" +#include "content/content_protected.h" #include "riscos/gui.h" #include "riscos/image.h" #include "riscos/sprite.h" @@ -49,19 +49,24 @@ * No conversion is necessary. We merely read the sprite dimensions. */ -bool sprite_convert(struct content *c, int width, int height) +bool sprite_convert(struct content *c) { os_error *error; int w, h; union content_msg_data msg_data; - void *source_data; + const char *source_data; + unsigned long source_size; + const void *sprite_data; + char title[100]; - source_data = ((char *)c->source_data) - 4; - osspriteop_area *area = (osspriteop_area*)source_data; + source_data = content__get_source_data(c, &source_size); + + sprite_data = source_data - 4; + osspriteop_area *area = (osspriteop_area*) sprite_data; c->data.sprite.data = area; /* check for bad data */ - if ((int)c->source_size + 4 != area->used) { + if ((int)source_size + 4 != area->used) { msg_data.error = messages_get("BadSprite"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); return false; @@ -81,10 +86,9 @@ bool sprite_convert(struct content *c, int width, int height) c->width = w; c->height = h; - c->title = malloc(100); - if (c->title) - snprintf(c->title, 100, messages_get("SpriteTitle"), c->width, - c->height, c->source_size); + snprintf(title, sizeof(title), messages_get("SpriteTitle"), c->width, + c->height, source_size); + content__set_title(c, title); c->status = CONTENT_STATUS_DONE; /* Done: update status bar */ content_set_status(c, ""); @@ -127,6 +131,18 @@ bool sprite_redraw(struct content *c, int x, int y, IMAGE_PLOT_OS); } +bool sprite_clone(const struct content *old, struct content *new_content) +{ + /* Simply rerun convert */ + if (old->status == CONTENT_STATUS_READY || + old->status == CONTENT_STATUS_DONE) { + if (sprite_convert(new_content) == false) + return false; + } + + return true; +} + #endif diff --git a/riscos/sprite.h b/riscos/sprite.h index 8bfe19b9e..2248cd400 100644 --- a/riscos/sprite.h +++ b/riscos/sprite.h @@ -34,12 +34,13 @@ struct content_sprite_data { void *data; }; -bool sprite_convert(struct content *c, int width, int height); +bool sprite_convert(struct content *c); void sprite_destroy(struct content *c); 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, colour background_colour); +bool sprite_clone(const struct content *old, struct content *new_content); #endif byte sprite_bpp(const osspriteop_header *s);