Commit 0b8f017d authored by Christian Persch's avatar Christian Persch

Add rsvg_get_surface_of_node

Similar to rsvg_get_pixbuf_of_node except that it returns a cairo_surface_t.
parent 55299625
......@@ -1974,6 +1974,12 @@ rsvg_get_image_of_node (RsvgDrawingCtx * ctx, RsvgNode * drawable, double w, dou
return ctx->render->get_image_of_node (ctx, drawable, w, h);
}
cairo_surface_t *
rsvg_get_surface_of_node (RsvgDrawingCtx * ctx, RsvgNode * drawable, double w, double h)
{
return ctx->render->get_surface_of_node (ctx, drawable, w, h);
}
void
rsvg_render_free (RsvgRender * render)
{
......
......@@ -127,6 +127,7 @@ rsvg_cairo_clip_render_new (cairo_t * cr, RsvgCairoRender *parent)
render->push_discrete_layer = rsvg_cairo_clip_push_discrete_layer;
render->add_clipping_rect = rsvg_cairo_clip_add_clipping_rect;
render->get_image_of_node = NULL;
render->get_surface_of_node = NULL;
cairo_render->initial_cr = parent->cr;
cairo_render->cr = cr;
clip_render->parent = parent;
......
......@@ -995,6 +995,41 @@ rsvg_cairo_get_image_of_node (RsvgDrawingCtx * ctx,
return img;
}
cairo_surface_t *
rsvg_cairo_get_surface_of_node (RsvgDrawingCtx *ctx,
RsvgNode *drawable,
double width,
double height)
{
cairo_surface_t *surface;
cairo_t *cr;
RsvgCairoRender *save_render = (RsvgCairoRender *) ctx->render;
RsvgCairoRender *render;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
cairo_surface_destroy (surface);
return NULL;
}
cr = cairo_create (surface);
render = rsvg_cairo_render_new (cr, width, height);
ctx->render = (RsvgRender *) render;
rsvg_state_push (ctx);
rsvg_node_draw (drawable, ctx, 0);
rsvg_state_pop (ctx);
cairo_destroy (cr);
rsvg_render_free (ctx->render);
ctx->render = (RsvgRender *) save_render;
return surface;
}
void
rsvg_cairo_to_pixbuf (guint8 * pixels, int rowstride, int height)
{
......
......@@ -46,6 +46,8 @@ void rsvg_cairo_add_clipping_rect (RsvgDrawingCtx *ctx,
GdkPixbuf *rsvg_cairo_get_image_of_node (RsvgDrawingCtx *ctx, RsvgNode *drawable,
double width, double height);
cairo_surface_t*rsvg_cairo_get_surface_of_node (RsvgDrawingCtx *ctx, RsvgNode *drawable,
double width, double height);
void rsvg_cairo_to_pixbuf (guint8 * pixels, int rowstride, int height);
void rsvg_pixbuf_to_cairo (guint8 * pixels, int rowstride, int height);
......
......@@ -32,6 +32,7 @@
#include <string.h>
#include "rsvg.h"
#include "rsvg-private.h"
#include "rsvg-cairo.h"
#include "rsvg-cairo-draw.h"
#include "rsvg-cairo-render.h"
......@@ -63,6 +64,7 @@ rsvg_cairo_render_new (cairo_t * cr, double width, double height)
cairo_render->super.push_discrete_layer = rsvg_cairo_push_discrete_layer;
cairo_render->super.add_clipping_rect = rsvg_cairo_add_clipping_rect;
cairo_render->super.get_image_of_node = rsvg_cairo_get_image_of_node;
cairo_render->super.get_surface_of_node = rsvg_cairo_get_surface_of_node;
cairo_render->width = width;
cairo_render->height = height;
cairo_render->offset_x = 0;
......
......@@ -224,6 +224,8 @@ struct RsvgRender {
double w, double h);
GdkPixbuf *(*get_image_of_node) (RsvgDrawingCtx * ctx, RsvgNode * drawable,
double w, double h);
cairo_surface_t *(*get_surface_of_node) (RsvgDrawingCtx * ctx, RsvgNode * drawable,
double w, double h);
};
static inline RsvgRender *
......@@ -379,7 +381,7 @@ void rsvg_render_image (RsvgDrawingCtx * ctx, GdkPixbuf * pb,
void rsvg_render_free (RsvgRender * render);
void rsvg_add_clipping_rect (RsvgDrawingCtx * ctx, double x, double y, double w, double h);
GdkPixbuf *rsvg_get_image_of_node (RsvgDrawingCtx * ctx, RsvgNode * drawable, double w, double h);
cairo_surface_t *rsvg_get_surface_of_node (RsvgDrawingCtx * ctx, RsvgNode * drawable, double w, double h);
void rsvg_node_set_atts (RsvgNode * node, RsvgHandle * ctx, RsvgPropertyBag * atts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment