37#include <librsvg/rsvg.h>
39#include <librsvg/rsvg-cairo.h>
42#include <nsutils/endian.h>
74 if ((c->
rsvgh = rsvg_handle_new()) == NULL) {
75 NSLOG(netsurf, INFO,
"rsvg_handle_new() returned NULL.");
87 bool quirks,
struct content **c)
97 llcache, fallback_charset, quirks);
121 if (rsvg_handle_write(d->
rsvgh, (
const guchar *)data, (gsize)
size,
124 "rsvg_handle_write returned an error: %s", err->message);
135 RsvgDimensionData rsvgsize;
138 if (rsvg_handle_close(d->
rsvgh, &err) == FALSE) {
140 "rsvg_handle_close returned an error: %s", err->message);
151 rsvg_handle_get_dimensions(d->
rsvgh, &rsvgsize);
152 c->
width = rsvgsize.width;
153 c->
height = rsvgsize.height;
158 "Failed to create bitmap for rsvg render.");
163 if ((d->
cs = cairo_image_surface_create_for_data(
169 "Failed to create Cairo image surface for rsvg render.");
174 if ((d->
ct = cairo_create(d->
cs)) == NULL) {
176 "Failed to create Cairo drawing context for rsvg render.");
181 rsvg_handle_render_cairo(d->
rsvgh, d->
ct);
184 .layout = BITMAP_LAYOUT_ARGB8888,
201 assert(rsvgcontent->
bitmap != NULL);
221 if (d->
rsvgh != NULL) g_object_unref(d->
rsvgh);
222 if (d->
ct != NULL) cairo_destroy(d->
ct);
223 if (d->
cs != NULL) cairo_surface_destroy(d->
cs);
268 *newc = (
struct content *) svg;
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.
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_SVG_ERROR
A SVG 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
Low-level resource cache (interface)
#define NSLOG(catname, level, logmsg, args...)
Localised message support (interface).
static bool rsvg_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
CONTENT_FACTORY_REGISTER_TYPES(nsrsvg, rsvg_types, rsvg_content_handler)
static bool rsvg_content_is_opaque(struct content *c)
static nserror rsvg_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
static nserror rsvg_create_svg_data(rsvg_content *c)
static void * rsvg_get_internal(const struct content *c, void *context)
static bool rsvg_convert(struct content *c)
static const char * rsvg_types[]
static bool rsvg_process_data(struct content *c, const char *data, unsigned int size)
struct rsvg_content rsvg_content
static const content_handler rsvg_content_handler
static void rsvg_destroy(struct content *c)
static nserror rsvg_clone(const struct content *old, struct content **newc)
static content_type rsvg_content_type(void)
Content handler for image/svg using librsvg (interface).
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 textsearch_context * context
content_status status
Current status.
unsigned int size
Estimated size of all data associated with this content.
void(* destroy)(void *bitmap)
Destroy a bitmap.
void *(* create)(int width, int height, enum gui_bitmap_flags flags)
Create a new bitmap.
size_t(* get_rowstride)(void *bitmap)
Get the number of bytes per row of the image.
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.
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.
cairo_surface_t * cs
The surface built inside a nsbitmap.
RsvgHandle * rsvgh
Context handle for RSVG renderer.
struct bitmap * bitmap
Created NetSurf bitmap.
cairo_t * ct
Cairo drawing context.
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.