30#include "oslib/drawfile.h"
46typedef struct draw_content {
56static bool draw_convert(
struct content *c);
57static void draw_destroy(
struct content *c);
65 .data_complete = draw_convert,
66 .destroy = draw_destroy,
67 .redraw = draw_redraw,
69 .type = draw_content_type,
73static const char *draw_types[] = {
74 "application/drawfile",
75 "application/x-drawfile",
90 draw = calloc(1,
sizeof(draw_content));
113bool draw_convert(
struct content *c)
115 draw_content *draw = (draw_content *) c;
117 const uint8_t *source_data;
128 error = xdrawfile_bbox(0, (drawfile_diagram *) data,
129 (
int) source_size, 0, &bbox);
131 NSLOG(netsurf, INFO,
"xdrawfile_bbox: 0x%x: %s",
132 error->errnum, error->errmess);
134 msg_data.errordata.errormsg = error->errmess;
139 if (bbox.x1 > bbox.x0 && bbox.y1 > bbox.y0) {
142 c->
width = ((bbox.x1 - bbox.x0) / 512);
143 c->
height = ((bbox.y1 - bbox.y0) / 512);
172void draw_destroy(
struct content *c)
184 draw_content *draw = (draw_content *) c;
186 const uint8_t *source_data;
188 const void *src_data;
198 src_data = source_data;
201 matrix.entries[0][0] = data->
width * 65536 / c->
width;
202 matrix.entries[0][1] = 0;
203 matrix.entries[1][0] = 0;
204 matrix.entries[1][1] = data->
height * 65536 / c->
height;
209 (data->
y + data->
height) * 512 -
212 error = xdrawfile_render(0, (drawfile_diagram *) src_data,
213 (int) source_size, &matrix, 0, 0);
215 NSLOG(netsurf, INFO,
"xdrawfile_render: 0x%x: %s",
216 error->errnum, error->errmess);
232 draw = calloc(1,
sizeof(draw_content));
245 if (draw_convert(&draw->base) ==
false) {
251 *newc = (
struct content *) draw;
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
Content for image/x-drawfile (RISC OS interface).
nserror
Enumeration of error codes.
@ NSERROR_UNKNOWN
Unknown error - DO NOT USE.
@ NSERROR_NOMEM
Memory exhaustion.
@ NSERROR_CLONE_FAILED
Failed to clone handle.
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...)
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.
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
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.