static rr_status_t
_grr_icon_init (grr_icon_t *icon, char *name)
{
- xsvg_status_t status;
+ svg_cairo_status_t status;
char *file, *buf;
int buflen;
icon->surface_width = 0;
icon->surface_height = 0;
- status = xsvg_create (&icon->xsvg);
+ status = svg_cairo_create (&icon->svg_cairo);
if (status)
return RR_STATUS_NO_MEMORY;
file = _grr_icon_find_file (name);
if (file) {
- status = xsvg_parse_file (icon->xsvg, file);
- if (status == XSVG_STATUS_SUCCESS) {
+ status = svg_cairo_parse (icon->svg_cairo, file);
+ if (status == SVG_CAIRO_STATUS_SUCCESS) {
free (file);
return RR_STATUS_SUCCESS;
}
}
_grr_icon_find_buffer (name, &buf, &buflen);
- status = xsvg_parse_buffer (icon->xsvg, buf, buflen);
+ status = svg_cairo_parse_buffer (icon->svg_cairo, buf, buflen);
if (status) {
fprintf (stderr, "Error parsing built-in SVG icon for: %s\n", name);
return RR_STATUS_PARSE_ERROR;
void
grr_icon_draw (grr_icon_t *icon, cairo_t *xrs)
{
- xsvg_status_t status;
+ svg_cairo_status_t status;
- status = xsvg_render (icon->xsvg, xrs);
+ status = svg_cairo_render (icon->svg_cairo, xrs);
if (status) {
- fprintf (stderr, "xsvg_render error\n");
+ fprintf (stderr, "svg_cairo_render error\n");
return;
}
}
void
grr_icon_predraw (grr_icon_t *icon, cairo_t *xrs, int width, int height)
{
+ cairo_t *xrs2;
+ cairo_matrix_t ctm;
+
if (icon->surface_width != width || icon->surface_height != height) {
if (icon->surface)
cairo_surface_destroy (icon->surface);
icon->surface_width = width;
icon->surface_height = height;
- icon->surface = cairo_surface_create_similar (cairo_current_target_surface (xrs),
+ icon->surface = cairo_surface_create_similar (cairo_get_target (xrs),
CAIRO_FORMAT_ARGB32,
width, height);
}
- cairo_save (xrs);
- cairo_set_target_surface (xrs, icon->surface);
- grr_icon_draw (icon, xrs);
- cairo_restore (xrs);
+ /* Need to copy the CTM from the original cairo_t to the new one */
+ xrs2 = cairo_create (icon->surface);
+ cairo_get_matrix (xrs, &ctm);
+ cairo_set_matrix (xrs2, &ctm);
+ grr_icon_draw (icon, xrs2);
+ cairo_destroy (xrs2);
}
void
-grr_icon_draw_predrawn (grr_icon_t *icon, cairo_t *xrs)
+grr_icon_draw_predrawn (grr_icon_t *icon, cairo_t *xrs, double alpha)
{
- if (icon->surface)
- cairo_show_surface (xrs, icon->surface, icon->surface_width, icon->surface_height);
+ if (icon->surface) {
+ cairo_set_source_surface (xrs, icon->surface, 0.0, 0.0);
+ cairo_paint_with_alpha (xrs, alpha);
+ }
}