28#include <librosprite.h>
52#define ERRCHK(x) do { \
53 rosprite_error err = x; \
54 if (err == ROSPRITE_EOF) { \
55 NSLOG(netsurf, INFO, "Got ROSPRITE_EOF when loading sprite file"); \
56 goto ro_sprite_error; \
57 } else if (err == ROSPRITE_BADMODE) { \
58 NSLOG(netsurf, INFO, "Got ROSPRITE_BADMODE when loading sprite file"); \
59 goto ro_sprite_error; \
60 } else if (err == ROSPRITE_OK) { \
62 goto ro_sprite_error; \
72 bool quirks,
struct content **c)
82 llcache, fallback_charset, quirks);
103 struct rosprite_mem_context* ctx = NULL;
111 ERRCHK(rosprite_create_mem_context((uint8_t *) data, size, &ctx));
113 struct rosprite_area* sprite_area;
114 ERRCHK(rosprite_load(rosprite_mem_reader, ctx, &sprite_area));
115 rosprite_destroy_mem_context(ctx);
118 assert(sprite_area->sprite_count > 0);
120 struct rosprite* sprite = sprite_area->sprites[0];
132 unsigned char *spritebuf = (
unsigned char *)sprite->image;
134 memcpy(imagebuf, spritebuf, sprite->width * sprite->height * 4);
136 c->
width = sprite->width;
137 c->
height = sprite->height;
149 .layout = BITMAP_LAYOUT_A8B8G8R8,
161 rosprite_destroy_mem_context(ctx);
178 rosprite_destroy_sprite_area(nssprite->
sprite_area);
179 if (nssprite->
bitmap != NULL)
237 *newc = (
struct content *) sprite;
259 if (nssprite->
bitmap != NULL) {
279 "image/x-riscos-sprite"
void content_destroy(struct content *c)
Destroy and free a content.
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.
void content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
Send an error message to all users.
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.
Internal core bitmap interface.
static void bitmap_format_to_client(void *bitmap, const bitmap_fmt_t *current_fmt)
Convert a bitmap to the client bitmap format.
nserror
Enumeration of error codes.
@ NSERROR_SPRITE_ERROR
A RISC OS Sprite error occurred.
@ NSERROR_NOMEM
Memory exhaustion.
@ NSERROR_CLONE_FAILED
Failed to clone handle.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
Generic bitmap handling interface.
Public content interface.
Target independent plotting interface.
unsigned long bitmap_flags_t
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)
char * messages_get_buff(const char *key,...)
Formatted message from a key in the global message hash.
Localised message support (interface).
static bool nssprite_convert(struct content *c)
Convert a CONTENT_SPRITE for display.
static void * nssprite_get_internal(const struct content *c, void *context)
static nserror nssprite_clone(const struct content *old, struct content **newc)
static bool nssprite_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Redraw a CONTENT_SPRITE.
static void nssprite_destroy(struct content *c)
Destroy a CONTENT_SPRITE and free all resources it owns.
static nserror nssprite_create(const 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)
static const content_handler nssprite_content_handler
CONTENT_FACTORY_REGISTER_TYPES(nssprite, nssprite_types, nssprite_content_handler)
static const char * nssprite_types[]
static content_type nssprite_content_type(void)
struct nssprite_content nssprite_content
static bool nssprite_content_is_opaque(struct content *c)
Content for image/x-riscos-sprite (librosprite interface).
const char * nsurl_access_leaf(const nsurl *url)
Access a URL's path leaf as a string.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
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
bool repeat_y
whether content is tiled in y direction
bool repeat_x
whether content is tiled in x direction
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.
int height
Height dimension, if applicable.
int width
Width dimension, if applicable.
struct llcache_handle * llcache
Low-level cache object.
struct textsearch_context * context
content_status status
Current status.
void(* destroy)(void *bitmap)
Destroy a bitmap.
void *(* create)(int width, int height, enum gui_bitmap_flags flags)
Create a new bitmap.
bool(* get_opaque)(void *bitmap)
Get the opacity of a bitmap.
void(* modified)(void *bitmap)
Marks a bitmap as modified.
unsigned char *(* get_buffer)(void *bitmap)
Get the image buffer from a bitmap.
Representation of an HTTP parameter.
Handle to low-level cache object.
struct gui_bitmap_table * bitmap
Bitmap table.
struct rosprite_area * sprite_area
struct bitmap * bitmap
Created NetSurf bitmap.
nserror(* bitmap)(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
const struct plotter_table * plot
Current plot operation table.
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.