33#include "oslib/wimp.h"
50#define AWRender_FileInitAddress 0x46080
51#define AWRender_RenderAddress 0x46081
52#define AWRender_DocBounds 0x46082
53#define AWRender_SendDefs 0x46083
54#define AWRender_ClaimVectors 0x46084
55#define AWRender_ReleaseVectors 0x46085
56#define AWRender_FindFirstFont 0x46086
57#define AWRender_FindNextFont 0x46087
60#define INITIAL_BLOCK_SIZE 0x1000
62typedef struct artworks_content {
68 void *render_workspace;
95extern os_error *awrender_init(
const char **doc,
100extern os_error *awrender_render(
const char *doc,
101 const struct awinfo_block *info,
102 const os_trfm *trans,
115 bool quirks,
struct content **c);
116static bool artworks_convert(
struct content *c);
117static void artworks_destroy(
struct content *c);
124 .
create = artworks_create,
125 .data_complete = artworks_convert,
126 .destroy = artworks_destroy,
127 .redraw = artworks_redraw,
128 .clone = artworks_clone,
129 .type = artworks_content_type,
133static const char *artworks_types[] = {
138 artworks_content_handler)
143 bool quirks,
struct content **c)
145 artworks_content *aw;
148 aw = calloc(1,
sizeof(artworks_content));
152 error =
content__init(&aw->base, handler, imime_type, params,
153 llcache, fallback_charset, quirks);
171bool artworks_convert(
struct content *c)
173 artworks_content *aw = (artworks_content *) c;
175 const uint8_t *source_data;
177 void *init_workspace;
185 xos_read_var_val_size(
"Alias$LoadArtWorksModules", 0, os_VARTYPE_STRING,
188 NSLOG(netsurf, INFO,
"Alias$LoadArtWorksModules not defined");
190 msg_data.errordata.errormsg =
messages_get(
"AWNotSeen");
196 error = xos_cli(
"LoadArtWorksModules");
198 NSLOG(netsurf, INFO,
"xos_cli: 0x%x: %s", error->errnum,
201 msg_data.errordata.errormsg = error->errmess;
207 error = (os_error*)_swix(AWRender_FileInitAddress, _OUT(0) | _OUT(1),
208 &init_routine, &init_workspace);
210 NSLOG(netsurf, INFO,
"AWRender_FileInitAddress: 0x%x: %s",
211 error->errnum, error->errmess);
213 msg_data.errordata.errormsg = error->errmess;
218 error = (os_error*)_swix(AWRender_RenderAddress, _OUT(0) | _OUT(1),
220 &aw->render_workspace);
222 NSLOG(netsurf, INFO,
"AWRender_RenderAddress: 0x%x: %s",
223 error->errnum, error->errmess);
225 msg_data.errordata.errormsg = error->errmess;
233 error = awrender_init((
const char **)&source_data, &source_size,
234 init_routine, init_workspace);
236 NSLOG(netsurf, INFO,
"awrender_init: 0x%x : %s",
237 error->errnum, error->errmess);
239 msg_data.errordata.errormsg = error->errmess;
244 error = (os_error*)_swix(AWRender_DocBounds,
245 _IN(0) | _OUT(2) | _OUT(3) | _OUT(4) | _OUT(5),
253 NSLOG(netsurf, INFO,
"AWRender_DocBounds: 0x%x: %s",
254 error->errnum, error->errmess);
256 msg_data.errordata.errormsg = error->errmess;
261 NSLOG(netsurf, INFO,
"bounding box: %d,%d,%d,%d", aw->x0, aw->y0,
267 aw->size = INITIAL_BLOCK_SIZE;
268 aw->block = malloc(INITIAL_BLOCK_SIZE);
271 "failed to create block for ArtworksRenderer");
278 c->
width = (aw->x1 - aw->x0) / 512;
279 c->
height = (aw->y1 - aw->y0) / 512;
300void artworks_destroy(
struct content *c)
302 artworks_content *aw = (artworks_content *) c;
316 os_MODEVAR_XEIG_FACTOR,
318 os_MODEVAR_YEIG_FACTOR,
323 artworks_content *aw = (artworks_content *) c;
324 struct awinfo_block info;
325 const uint8_t *source_data;
331 int clip_x0 =
clip->x0;
332 int clip_y0 =
clip->y0;
333 int clip_x1 =
clip->x1;
334 int clip_y1 =
clip->y1;
341 (void)_swix(AWRender_RenderAddress, _OUT(0) | _OUT(1),
343 &aw->render_workspace);
346 matrix.entries[0][0] = data->
width * 65536 / c->
width;
347 matrix.entries[0][1] = 0;
348 matrix.entries[1][0] = 0;
349 matrix.entries[1][1] = data->
height * 65536 / c->
height;
354 (data->
y + data->
height) * 512 -
365 if (data->
scale == 1.0) {
366 info.clip_x0 = (clip_x0 * 512) + aw->x0 - 511;
367 info.clip_y0 = ((c->
height - clip_y1) * 512) + aw->y0 - 511;
368 info.clip_x1 = (clip_x1 * 512) + aw->x0 + 511;
369 info.clip_y1 = ((c->
height - clip_y0) * 512) + aw->y0 + 511;
372 info.clip_x0 = (clip_x0 * 512 / data->
scale) + aw->x0 - 511;
373 info.clip_y0 = ((c->
height - (clip_y1 / data->
scale)) * 512) +
375 info.clip_x1 = (clip_x1 * 512 / data->
scale) + aw->x0 + 511;
376 info.clip_y1 = ((c->
height - (clip_y0 / data->
scale)) * 512) +
382 info.print_handle = 0;
387 NSLOG(netsurf, INFO,
"xos_read_vdu_variables: 0x%x: %s",
388 error->errnum, error->errmess);
392 error = xwimp_read_palette((os_palette*)&vals[3]);
394 NSLOG(netsurf, INFO,
"xwimp_read_palette: 0x%x: %s",
395 error->errnum, error->errmess);
401 error = awrender_render((
const char *)source_data,
411 aw->render_workspace);
414 NSLOG(netsurf, INFO,
"awrender_render: 0x%x: %s",
415 error->errnum, error->errmess);
424 artworks_content *aw;
427 aw = calloc(1,
sizeof(artworks_content));
440 if (artworks_convert(&aw->base) ==
false) {
Content for image/x-artworks (RISC OS interface).
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.
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.
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)
float scale
Scale for redraw (for scaling contents without 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.
content_status status
Current status.
unsigned int size
Estimated size of all data associated with this content.
Representation of an HTTP parameter.
Handle to low-level cache object.
nserror(* flush)(const struct redraw_context *ctx)
Only used internally by the knockout code.
const struct plotter_table * plot
Current plot operation table.
Extra data for some content_msg messages.
void * ctx
context passed to browser_window_search()
Interface to a number of general purpose functionality.
A collection of grubby utilities for working with OSLib's wimp API.
#define PTR_OS_VDU_VAR_LIST(l)
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.