Commit 9d65c44b authored by Caleb Michael Moore's avatar Caleb Michael Moore

fancy new partial render api

parent 85b7070c
2005-11-26 Caleb Moore <c.moore@student.unsw.edu.au>
* rsvg-cairo-render.c, rsvg.c, rsvg.h: made that partial rendering api that I promised Rahga ages ago. Havn't tested yet.
2005-11-25 Dom Lachowicz <cinamod@hotmail.com> 2005-11-25 Dom Lachowicz <cinamod@hotmail.com>
* configure.in: 2.13.3 * configure.in: 2.13.3
......
...@@ -59,9 +59,6 @@ ...@@ -59,9 +59,6 @@
static double internal_dpi_x = RSVG_DEFAULT_DPI_X; static double internal_dpi_x = RSVG_DEFAULT_DPI_X;
static double internal_dpi_y = RSVG_DEFAULT_DPI_Y; static double internal_dpi_y = RSVG_DEFAULT_DPI_Y;
void
rsvg_drawing_ctx_init(RsvgDrawingCtx * handle);
static void static void
rsvg_ctx_free_helper (gpointer key, gpointer value, gpointer user_data) rsvg_ctx_free_helper (gpointer key, gpointer value, gpointer user_data)
{ {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <glib/gslist.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
...@@ -97,6 +98,7 @@ rsvg_cairo_new_drawing_ctx (cairo_t *cr, RsvgHandle *handle) ...@@ -97,6 +98,7 @@ rsvg_cairo_new_drawing_ctx (cairo_t *cr, RsvgHandle *handle)
draw->vb.w = data.em; draw->vb.w = data.em;
draw->vb.h = data.ex; draw->vb.h = data.ex;
draw->pango_context = NULL; draw->pango_context = NULL;
draw->drawsub_stack = NULL;
rsvg_state_push(draw); rsvg_state_push(draw);
...@@ -118,7 +120,10 @@ rsvg_cairo_new_drawing_ctx (cairo_t *cr, RsvgHandle *handle) ...@@ -118,7 +120,10 @@ rsvg_cairo_new_drawing_ctx (cairo_t *cr, RsvgHandle *handle)
} }
void void
rsvg_cairo_render (cairo_t *cr, RsvgHandle *handle) rsvg_cairo_render_sub(cairo_t *cr, RsvgHandle *handle, RsvgNode *drawsub);
void
rsvg_cairo_render_sub (cairo_t *cr, RsvgHandle *handle, RsvgNode * drawsub)
{ {
RsvgDrawingCtx * draw; RsvgDrawingCtx * draw;
g_return_if_fail (handle != NULL); g_return_if_fail (handle != NULL);
...@@ -130,8 +135,19 @@ rsvg_cairo_render (cairo_t *cr, RsvgHandle *handle) ...@@ -130,8 +135,19 @@ rsvg_cairo_render (cairo_t *cr, RsvgHandle *handle)
if (!draw) if (!draw)
return; return;
while (drawsub != NULL){
draw->drawsub_stack = g_slist_prepend(draw->drawsub_stack, drawsub);
drawsub = drawsub->parent;
}
rsvg_state_push(draw); rsvg_state_push(draw);
rsvg_node_draw((RsvgNode *)handle->treebase, draw, 0); rsvg_node_draw((RsvgNode *)handle->treebase, draw, 0);
rsvg_state_pop(draw); rsvg_state_pop(draw);
rsvg_drawing_ctx_free(draw); rsvg_drawing_ctx_free(draw);
} }
void
rsvg_cairo_render (cairo_t *cr, RsvgHandle *handle)
{
rsvg_cairo_render_sub(cr, handle, NULL);
}
...@@ -611,6 +611,8 @@ rsvg_filter_get_result (GString * name, RsvgFilterContext * ctx) ...@@ -611,6 +611,8 @@ rsvg_filter_get_result (GString * name, RsvgFilterContext * ctx)
{ {
RsvgFilterPrimitiveOutput output; RsvgFilterPrimitiveOutput output;
RsvgFilterPrimitiveOutput * outputpointer; RsvgFilterPrimitiveOutput * outputpointer;
output.bounds.x0 = output.bounds.x1 =
output.bounds.y0 = output.bounds.y1 = 0;
if (!strcmp (name->str, "SourceGraphic")) if (!strcmp (name->str, "SourceGraphic"))
{ {
......
...@@ -135,6 +135,7 @@ struct RsvgDrawingCtx { ...@@ -135,6 +135,7 @@ struct RsvgDrawingCtx {
double dpi_x, dpi_y; double dpi_x, dpi_y;
RsvgViewBox vb; RsvgViewBox vb;
GSList * vb_stack; GSList * vb_stack;
GSList * drawsub_stack;
}; };
/*Abstract base class for context for our backends (one as yet)*/ /*Abstract base class for context for our backends (one as yet)*/
......
...@@ -38,13 +38,21 @@ rsvg_node_draw (RsvgNode * self, RsvgDrawingCtx *ctx, ...@@ -38,13 +38,21 @@ rsvg_node_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
int dominate) int dominate)
{ {
RsvgState *state; RsvgState *state;
GSList * stacksave;
state = self->state; state = self->state;
stacksave = ctx->drawsub_stack;
if (stacksave){
if (stacksave->data != self)
return;
ctx->drawsub_stack = stacksave->next;
}
if (0 /*!state->visible*/) if (0 /*!state->visible*/)
return; return;
self->draw(self, ctx, dominate); self->draw(self, ctx, dominate);
ctx->drawsub_stack = stacksave;
} }
/* generic function for drawing all of the children of a particular node */ /* generic function for drawing all of the children of a particular node */
......
...@@ -43,26 +43,17 @@ ...@@ -43,26 +43,17 @@
#include "rsvg-cairo.h" #include "rsvg-cairo.h"
#include "rsvg-cairo-draw.h" #include "rsvg-cairo-draw.h"
void
rsvg_cairo_render_sub(cairo_t *cr, RsvgHandle *handle, RsvgNode *drawsub);
static void static void
rsvg_pixmap_destroy (gchar *pixels, gpointer data) rsvg_pixmap_destroy (gchar *pixels, gpointer data)
{ {
g_free (pixels); g_free (pixels);
} }
/**
* rsvg_handle_get_pixbuf:
* @handle: An #RsvgHandle
*
* Returns the pixbuf loaded by #handle. The pixbuf returned will be reffed, so
* the caller of this function must assume that ref. If insufficient data has
* been read to create the pixbuf, or an error occurred in loading, then %NULL
* will be returned. Note that the pixbuf may not be complete until
* @rsvg_handle_close has been called.
*
* Returns: the pixbuf loaded by #handle, or %NULL.
**/
GdkPixbuf * GdkPixbuf *
rsvg_handle_get_pixbuf (RsvgHandle *handle) rsvg_handle_get_pixbuf_sub (RsvgHandle *handle, char * id)
{ {
RsvgDimensionData dimensions; RsvgDimensionData dimensions;
GdkPixbuf *output = NULL; GdkPixbuf *output = NULL;
...@@ -88,8 +79,11 @@ rsvg_handle_get_pixbuf (RsvgHandle *handle) ...@@ -88,8 +79,11 @@ rsvg_handle_get_pixbuf (RsvgHandle *handle)
cr = cairo_create (surface); cr = cairo_create (surface);
rsvg_cairo_render (cr, handle); if (id == NULL)
rsvg_cairo_render (cr, handle);
else
rsvg_cairo_render_sub (cr, handle,
rsvg_defs_lookup (handle->defs, id));
rsvg_cairo_to_pixbuf(pixels, rowstride, dimensions.height); rsvg_cairo_to_pixbuf(pixels, rowstride, dimensions.height);
output = gdk_pixbuf_new_from_data (pixels, output = gdk_pixbuf_new_from_data (pixels,
...@@ -107,3 +101,22 @@ rsvg_handle_get_pixbuf (RsvgHandle *handle) ...@@ -107,3 +101,22 @@ rsvg_handle_get_pixbuf (RsvgHandle *handle)
return output; return output;
} }
/**
* rsvg_handle_get_pixbuf:
* @handle: An #RsvgHandle
*
* Returns the pixbuf loaded by #handle. The pixbuf returned will be reffed, so
* the caller of this function must assume that ref. If insufficient data has
* been read to create the pixbuf, or an error occurred in loading, then %NULL
* will be returned. Note that the pixbuf may not be complete until
* @rsvg_handle_close has been called.
*
* Returns: the pixbuf loaded by #handle, or %NULL.
**/
GdkPixbuf *
rsvg_handle_get_pixbuf (RsvgHandle *handle)
{
return rsvg_handle_get_pixbuf_sub (handle, NULL);
}
...@@ -62,6 +62,7 @@ gboolean rsvg_handle_write (RsvgHandle *handle, ...@@ -62,6 +62,7 @@ gboolean rsvg_handle_write (RsvgHandle *handle,
gboolean rsvg_handle_close (RsvgHandle *handle, gboolean rsvg_handle_close (RsvgHandle *handle,
GError **error); GError **error);
GdkPixbuf *rsvg_handle_get_pixbuf (RsvgHandle *handle); GdkPixbuf *rsvg_handle_get_pixbuf (RsvgHandle *handle);
GdkPixbuf *rsvg_handle_get_pixbuf_sub (RsvgHandle *handle, char * id);
void rsvg_handle_free (RsvgHandle *handle); void rsvg_handle_free (RsvgHandle *handle);
G_CONST_RETURN char * G_CONST_RETURN char *
......
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