37#include <librsvg/rsvg.h>
39#include <nsutils/endian.h>
67 lwc_string *imime_type,
104 RsvgRectangle viewport;
108 NSLOG(netsurf, INFO,
"Failed to create bitmap for rsvg render.");
112 if ((cs = cairo_image_surface_create_for_data(
117 NSLOG(netsurf, INFO,
"Failed to create Cairo image surface for rsvg render.");
121 if ((cr = cairo_create(cs)) == NULL) {
123 "Failed to create Cairo drawing context for rsvg render.");
124 cairo_surface_destroy(cs);
131 viewport.width = c->
width;
132 viewport.height = c->
height;
133 renderres = rsvg_handle_render_document(svgc->
rsvgh, cr, &viewport, NULL);
134 NSLOG(netsurf, DEBUG,
"rsvg render:%d, width:%d, height %d", renderres, c->
width, c->
height);
142 cairo_surface_destroy(cs);
150#if LIBRSVG_MAJOR_VERSION >= 2 && LIBRSVG_MINOR_VERSION >= 52
155 gotsize = rsvg_handle_get_intrinsic_size_in_pixels(svgc->
rsvgh,
158 if (gotsize == TRUE) {
162 RsvgRectangle ink_rect;
163 RsvgRectangle logical_rect;
164 rsvg_handle_get_geometry_for_element(svgc->
rsvgh,
169 *
width = ink_rect.width;
170 *
height = ink_rect.height;
173 RsvgDimensionData rsvgsize;
175 rsvg_handle_get_dimensions(svgc->
rsvgh, &rsvgsize);
176 *
width = rsvgsize.width;
177 *
height = rsvgsize.height;
187 GInputStream * istream;
188 GError *gerror = NULL;
194 istream = g_memory_input_stream_new_from_data(data,
size, NULL);
195 svgc->
rsvgh = rsvg_handle_new_from_stream_sync(istream,
197 RSVG_HANDLE_FLAGS_NONE,
200 g_object_unref(istream);
201 if (svgc->
rsvgh == NULL) {
202 NSLOG(netsurf, INFO,
"Failed to create rsvg handle for content.");
254 if (d->
rsvgh != NULL) {
255 g_object_unref(d->
rsvgh);
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.
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.
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_NOMEM
Memory exhaustion.
@ NSERROR_CLONE_FAILED
Failed to clone handle.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
content_type image_cache_content_type(void)
void * image_cache_get_internal(const struct content *c, void *context)
bool image_cache_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Generic content redraw callback.
void image_cache_destroy(struct content *content)
nserror image_cache_add(struct content *content, struct bitmap *bitmap, image_cache_convert_fn *convert)
adds an image content to be cached.
bool image_cache_is_opaque(struct content *c)
The image content handler intermediate image cache.
Generic bitmap handling interface.
@ BITMAP_LAYOUT_ARGB8888
32-bit ARGB (0xAARRGGBB).
Public content interface.
Target independent plotting interface.
static struct llcache_s * llcache
low level cache state
Low-level resource cache (interface)
#define NSLOG(catname, level, logmsg, args...)
Localised message support (interface).
CONTENT_FACTORY_REGISTER_TYPES(nsrsvg, rsvg_types, rsvg_content_handler)
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 struct bitmap * rsvg_cache_convert(struct content *c)
create a bitmap from jpeg content for the image cache.
static bool rsvg_convert(struct content *c)
static const char * rsvg_types[]
struct rsvg_content rsvg_content
static void rsvg__get_demensions(const rsvg_content *svgc, int *width, int *height)
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)
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)
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.
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.
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.
RsvgHandle * rsvgh
Context handle for RSVG renderer.
Interface to a number of general purpose functionality.
static 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.