NetSurf
Data Structures | Typedefs | Functions | Variables
rsvg246.c File Reference

implementation of content handler for image/svg using librsvg 2.46 API. More...

#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <string.h>
#include <sys/types.h>
#include <librsvg/rsvg.h>
#include <nsutils/endian.h>
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/messages.h"
#include "netsurf/plotters.h"
#include "netsurf/bitmap.h"
#include "netsurf/content.h"
#include "content/llcache.h"
#include "content/content_protected.h"
#include "content/content_factory.h"
#include "desktop/gui_internal.h"
#include "desktop/bitmap.h"
#include "image/image_cache.h"
#include "image/rsvg.h"
Include dependency graph for rsvg246.c:

Go to the source code of this file.

Data Structures

struct  rsvg_content
 

Typedefs

typedef struct rsvg_content rsvg_content
 

Functions

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 bitmaprsvg_cache_convert (struct content *c)
 create a bitmap from jpeg content for the image cache. More...
 
static void rsvg__get_demensions (const rsvg_content *svgc, int *width, int *height)
 
static bool rsvg_convert (struct content *c)
 
static nserror rsvg_clone (const struct content *old, struct content **newc)
 
static void rsvg_destroy (struct content *c)
 
 CONTENT_FACTORY_REGISTER_TYPES (nsrsvg, rsvg_types, rsvg_content_handler)
 

Variables

static const content_handler rsvg_content_handler
 
static const char * rsvg_types []
 

Detailed Description

implementation of content handler for image/svg using librsvg 2.46 API.

SVG files are rendered to a NetSurf bitmap by creating a Cairo rendering surface (content_rsvg_data.cs) over the bitmap's data, creating a Cairo drawing context using that surface, and then passing that drawing context to librsvg which then uses Cairo calls to plot the graphic to the bitmap. We store this in content->bitmap, and then use the usual bitmap plotter function to render it for redraw requests.

Definition in file rsvg246.c.

Typedef Documentation

◆ rsvg_content

typedef struct rsvg_content rsvg_content

Function Documentation

◆ CONTENT_FACTORY_REGISTER_TYPES()

CONTENT_FACTORY_REGISTER_TYPES ( nsrsvg  ,
rsvg_types  ,
rsvg_content_handler   
)

◆ rsvg__get_demensions()

static void rsvg__get_demensions ( const rsvg_content svgc,
int *  width,
int *  height 
)
static

Definition at line 147 of file rsvg246.c.

References height, NSLOG, rsvg_content::rsvgh, and width.

Referenced by rsvg_convert().

Here is the caller graph for this function:

◆ rsvg_cache_convert()

static struct bitmap * rsvg_cache_convert ( struct content c)
static

create a bitmap from jpeg content for the image cache.

Definition at line 98 of file rsvg246.c.

References netsurf_table::bitmap, bitmap(), bitmap_format_to_client(), BITMAP_LAYOUT_ARGB8888, BITMAP_NONE, gui_bitmap_table::create, gui_bitmap_table::destroy, gui_bitmap_table::get_buffer, gui_bitmap_table::get_rowstride, guit, content::height, gui_bitmap_table::modified, NSLOG, rsvg_content::rsvgh, and content::width.

Referenced by rsvg_convert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rsvg_clone()

static nserror rsvg_clone ( const struct content old,
struct content **  newc 
)
static

Definition at line 220 of file rsvg246.c.

References rsvg_content::base, content__clone(), content_destroy(), CONTENT_STATUS_DONE, CONTENT_STATUS_READY, NSERROR_CLONE_FAILED, NSERROR_NOMEM, NSERROR_OK, rsvg_convert(), and content::status.

Here is the call graph for this function:

◆ rsvg_convert()

static bool rsvg_convert ( struct content c)
static

Definition at line 182 of file rsvg246.c.

References content__get_source_data(), content_set_done(), content_set_ready(), content_set_status(), content::height, image_cache_add(), NSLOG, rsvg__get_demensions(), rsvg_cache_convert(), rsvg_content::rsvgh, content::size, bitmap::size, and content::width.

Referenced by rsvg_clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rsvg_create()

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

Definition at line 66 of file rsvg246.c.

References rsvg_content::base, content__init(), content::fallback_charset, content::handler, llcache, NSERROR_NOMEM, NSERROR_OK, and content::quirks.

Here is the call graph for this function:

◆ rsvg_destroy()

static void rsvg_destroy ( struct content c)
static

Definition at line 250 of file rsvg246.c.

References image_cache_destroy(), and rsvg_content::rsvgh.

Here is the call graph for this function:

Variable Documentation

◆ rsvg_content_handler

const content_handler rsvg_content_handler
static
Initial value:
= {
.create = rsvg_create,
.data_complete = rsvg_convert,
.destroy = rsvg_destroy,
.redraw = image_cache_redraw,
.clone = rsvg_clone,
.get_internal = image_cache_get_internal,
.is_opaque = image_cache_is_opaque,
.no_share = false,
}
content_type image_cache_content_type(void)
Definition: image_cache.c:873
void * image_cache_get_internal(const struct content *c, void *context)
Definition: image_cache.c:856
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.
Definition: image_cache.c:798
bool image_cache_is_opaque(struct content *c)
Definition: image_cache.c:862
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)
Definition: rsvg246.c:66
static bool rsvg_convert(struct content *c)
Definition: rsvg246.c:182
static void rsvg_destroy(struct content *c)
Definition: rsvg246.c:250
static nserror rsvg_clone(const struct content *old, struct content **newc)
Definition: rsvg246.c:220

Definition at line 262 of file rsvg246.c.

◆ rsvg_types

const char* rsvg_types[]
static
Initial value:
= {
"image/svg",
"image/svg+xml"
}

Definition at line 274 of file rsvg246.c.