29#include "oslib/osspriteop.h"
49typedef struct sprite_content {
59static bool sprite_convert(
struct content *c);
60static void sprite_destroy(
struct content *c);
68 .data_complete = sprite_convert,
69 .destroy = sprite_destroy,
70 .redraw = sprite_redraw,
71 .clone = sprite_clone,
72 .type = sprite_content_type,
76static const char *sprite_types[] = {
77 "image/x-riscos-sprite"
87 sprite_content *sprite;
90 sprite = calloc(1,
sizeof(sprite_content));
101 *c = (
struct content *) sprite;
112bool sprite_convert(
struct content *c)
114 sprite_content *sprite = (sprite_content *) c;
118 const uint8_t *source_data;
120 const void *sprite_data;
125 sprite_data = source_data - 4;
126 osspriteop_area *
area = (osspriteop_area*) sprite_data;
130 if ((
int)source_size + 4 !=
area->used) {
132 msg_data.errordata.errormsg =
messages_get(
"BadSprite");
137 error = xosspriteop_read_sprite_info(osspriteop_PTR,
138 (osspriteop_area *)0x100,
139 (osspriteop_id) ((
char *)
area +
area->first),
143 "xosspriteop_read_sprite_info: 0x%x: %s",
147 msg_data.errordata.errormsg = error->errmess;
175void sprite_destroy(
struct content *c)
189 sprite_content *sprite = (sprite_content *) c;
207 sprite_content *sprite;
210 sprite = calloc(1,
sizeof(sprite_content));
223 if (sprite_convert(&sprite->base) ==
false) {
229 *newc = (
struct content *) sprite;
253 int type = ((unsigned)s->mode >> osspriteop_TYPE_SHIFT) & 15;
257 case osspriteop_TYPE_OLD:
261 if (!xos_read_mode_variable(s->mode,
262 os_MODEVAR_LOG2_BPP, &val, &psr) &&
267 case osspriteop_TYPE1BPP: bpp = 1;
break;
268 case osspriteop_TYPE2BPP: bpp = 2;
break;
269 case osspriteop_TYPE4BPP: bpp = 4;
break;
270 case osspriteop_TYPE8BPP: bpp = 8;
break;
271 case osspriteop_TYPE16BPP: bpp = 16;
break;
272 case osspriteop_TYPE32BPP: bpp = 32;
break;
273 case osspriteop_TYPE_CMYK: bpp = 32;
break;
Content handling interface.
void content_destroy(struct content *c)
Destroy and free a content.
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
void content_set_done(struct content *c)
Put a content in status CONTENT_STATUS_DONE.
bool content__set_title(struct content *c, const char *title)
Set title associated with content.
nserror content__init(struct content *c, const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks)
const uint8_t * content__get_source_data(struct content *c, size_t *size)
Retrieve source of content.
nserror content__clone(const struct content *c, struct content *nc)
Clone a content's data members.
void content_set_ready(struct content *c)
Put a content in status CONTENT_STATUS_READY and unlock the content.
void content_set_status(struct content *c, const char *status_message)
Updates content with new status.
#define CONTENT_FACTORY_REGISTER_TYPES(HNAME, HTYPELIST, HHANDLER)
Protected interface to Content handling.
@ CONTENT_STATUS_READY
Some parts of content still being loaded, but can be displayed.
@ CONTENT_STATUS_DONE
Content has completed all processing.
content_type
The type of a content.
@ CONTENT_IMAGE
All images.
@ CONTENT_MSG_ERROR
error occurred
nserror
Enumeration of error codes.
@ NSERROR_UNKNOWN
Unknown error - DO NOT USE.
@ NSERROR_NOMEM
Memory exhaustion.
@ NSERROR_CLONE_FAILED
Failed to clone handle.
bool image_redraw(osspriteop_area *area, int x, int y, int req_width, int req_height, int width, int height, colour background_colour, bool repeatx, bool repeaty, bool background, image_type type)
Plot an image at the given coordinates using the method specified.
Public content interface.
Target independent plotting interface.
static struct llcache_s * llcache
low level cache state
nsurl * llcache_handle_get_url(const llcache_handle *handle)
Retrieve the post-redirect URL of a low-level cache object.
Low-level resource cache (interface)
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
char * messages_get_buff(const char *key,...)
Formatted message from a key in the global message hash.
Localised message support (interface).
const char * nsurl_access_leaf(const nsurl *url)
Access a URL's path leaf as a string.
byte sprite_bpp(const osspriteop_header *s)
Returns the bit depth of a sprite.
Content for image/x-riscos-sprite (RISC OS interface).
Interface to utility string handling.
Content operation function table.
nserror(* create)(const struct content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, struct llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
parameters to content redraw
int height
vertical dimension
int y
coordinate for top-left of redraw
int x
coordinate for top-left of redraw
colour background_colour
The background colour.
int width
dimensions to render content at (for scaling contents with intrinsic dimensions)
Content which corresponds to a single URL.
bool quirks
Content is in quirks mode.
int height
Height dimension, if applicable.
char * fallback_charset
Fallback charset, or NULL.
int width
Width dimension, if applicable.
const struct content_handler * handler
Handler for content.
struct llcache_handle * llcache
Low-level cache object.
content_status status
Current status.
Representation of an HTTP parameter.
Handle to low-level cache object.
Extra data for some content_msg messages.
void * ctx
context passed to browser_window_search()
Interface to a number of general purpose functionality.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.