Commit eff0cd74 authored by Dom Lachowicz's avatar Dom Lachowicz

update TODO, improve RsvgRender interface

parent 72aed17f
2005-02-26 Dom Lachowicz <cinamod@hotmail.com>
* rsvg-private.h: Move M_PI's definition here
* rsvg-private.h: Add rsvg_render_free ()
* rsvg-art-render.c: 2 implementations of ^^
* *: Changes to pass RsvgBpathDefs instead of "const char * d" to renders
* TODO: update to reflect some of the work remaining
2005-02-25 Dom Lachowicz <cinamod@hotmail.com>
* *: Get rid of deprecated stuff.
......
TODO:
High Priority (absolutely must be done before our next major release - GNOME 3.0):
* Add GError support in the loader, rather then the g_warnings
that we currently use.
* Implement a Cairo RsvgRender backend (http://www.cairographics.org/)
* Enables us to draw directly onto X11 Drawables, OSX/Quartz, and Win32 HDCs, rather than a RGBA buffer that later gets composited.
* Enables printing to PS/PDF.
* Ensures that our baby isn't thrown out with the bathwater in GNOME 3.0, where libart's (stupid...) deprecation takes effect.
* Make error messages translatable (requires adding gettext).
* Split librsvg into several separate libraries in order to decrease dependencies and increase modularity
* librsvg-base
* librsvg-libart
* librsvg-cairo
* ...
* Stabilize the API/ABI for the GNOME 3.0 timeframe
* Give librsvg a thorough valgrinding and a code/organizational sanity check. No memleaks or errors are acceptable.
* Pay special attention to be sure that the RsvgRenders get free'd.
* Split out the libart and cairo code into their own subdirs.
* Try to pass much of the SVG 1.1 static conformance test
* Try to pass as many tests as possible. We're shooting for 90% +.
* Upload the tests and our results into a matrix online somewhere, maybe Wiki-based.
* Speed improvements whenever possible
* Some initial tests show that using Cairo instead of libart for SVG->PNG might be a big win.
* Decrease memory usage whenever possible
* Improvements to the Mozilla plugin
* Possibly use a Cairo backend to draw directly onto Mozilla's Drawable, rather than using our XEmbed hack.
* Should enable proper translucency, but could be SLOW
* Enable printing support, integrated with Mozilla's (http://wp.netscape.com/eng/mozilla/3.0/handbook/plugins/pi4.htm#npprint)
* Ideally would use Cairo->PS for this
* In a pinch, embedding a PNG inside of a PS snippet would also work
* Improvements to the rsvg-view application
* Add zooming
* Add panning
* Improvements to the rsvg application
* Support input from stdin
* Areas in need of improvement:
* Switch/conditionals
* Text
* Whitespace issues
* "International" issues - bi-directional, top->bottom, etc.
* Text along paths
* Fonts
* CSS-defined fonts (do we want to support this?)
* SVG fonts (do we want to support this?)
Lower Priority:
* Any SVG 1.2 features that we want to sneak in. SVG 1.2 conformance is not a priority. Top candidates include:
* <multiImage>
* <pageSet>
* Improved GError support in the loader and error propegation, rather then the g_warnings that we currently use.
* Make error messages translatable (requires adding gettext).
* Improved Gimp plugin (choose 1 of "A" or "B". "A" would be easier, but perhaps less compelling. Jimmac and Tigert would be estatic if we could do either.)
* A) Store layer names, composite layers onto the Gimp itself
* B) Implement a Gimp-based RsvgRender that drew SVGs in terms of Gimp's path, gradient, pattern, etc. APIs
......@@ -26,10 +26,6 @@
#include <stdio.h>
#include <string.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif /* M_PI */
/**
* _rsvg_affine_invert: Find the inverse of an affine transformation.
* @dst: Where the resulting affine is stored.
......
......@@ -479,7 +479,7 @@ rsvg_art_alpha_blt (GdkPixbuf * src, gint srcx, gint srcy, gint srcwidth,
}
void
rsvg_art_affine_image(GdkPixbuf *img, GdkPixbuf *intermediate,
rsvg_art_affine_image(const GdkPixbuf *img, GdkPixbuf *intermediate,
double * affine, double w, double h)
{
gdouble tmp_affine[6];
......
......@@ -43,7 +43,7 @@ void rsvg_art_alpha_blt (GdkPixbuf * src, gint srcx, gint srcy,
gint srcwidth, gint srcheight,
GdkPixbuf * dst, gint dstx, gint dsty);
void rsvg_art_clip_image (GdkPixbuf *intermediate, ArtSVP *path);
void rsvg_art_affine_image(GdkPixbuf *img, GdkPixbuf *intermediate,
void rsvg_art_affine_image(const GdkPixbuf *img, GdkPixbuf *intermediate,
double * affine, double w, double h);
void rsvg_art_add_clipping_rect(RsvgDrawingCtx *ctx, double x, double y, double w, double h);
G_END_DECLS
......
......@@ -418,7 +418,7 @@ rsvg_render_bpath_into_svp (RsvgDrawingCtx *ctx, const ArtBpath *bpath)
}
static void
rsvg_render_markers(RsvgBpathDef * bpath_def, RsvgDrawingCtx *ctx)
rsvg_render_markers(const RsvgBpathDef * bpath_def, RsvgDrawingCtx *ctx)
{
int i;
......@@ -459,7 +459,6 @@ rsvg_render_markers(RsvgBpathDef * bpath_def, RsvgDrawingCtx *ctx)
state->affine[2] * bpath_def->bpath[i + 1].y3 + state->affine[4];
nexty = state->affine[1] * bpath_def->bpath[i + 1].x3 +
state->affine[3] * bpath_def->bpath[i + 1].y3 + state->affine[5];
if(bpath_def->bpath[i + 1].code == ART_MOVETO ||
bpath_def->bpath[i + 1].code == ART_MOVETO_OPEN ||
......@@ -500,31 +499,19 @@ rsvg_render_markers(RsvgBpathDef * bpath_def, RsvgDrawingCtx *ctx)
}
void
rsvg_art_render_path(RsvgDrawingCtx *ctx, const char *d)
rsvg_art_render_path(RsvgDrawingCtx *ctx, const RsvgBpathDef *bpath_def)
{
RsvgBpathDef *bpath_def;
bpath_def = rsvg_parse_path (d);
rsvg_bpath_def_art_finish (bpath_def);
rsvg_render_bpath (ctx, (ArtBpath *)bpath_def->bpath);
rsvg_render_markers(bpath_def, ctx);
rsvg_bpath_def_free (bpath_def);
}
void
rsvg_art_svp_render_path (RsvgDrawingCtx *ctx, const char *d)
rsvg_art_svp_render_path (RsvgDrawingCtx *ctx, const RsvgBpathDef *bpath_def)
{
RsvgBpathDef *bpath_def;
RsvgArtSVPRender *render = (RsvgArtSVPRender *)ctx->render;
ArtSVP *svp2, *svp3;
bpath_def = rsvg_parse_path (d);
rsvg_bpath_def_art_finish (bpath_def);
svp2 = rsvg_render_bpath_into_svp (ctx, (ArtBpath *)bpath_def->bpath);
svp2 = rsvg_render_bpath_into_svp (ctx, (ArtBpath *)bpath_def->bpath);
if (render->outline != NULL)
{
......@@ -534,11 +521,9 @@ rsvg_art_svp_render_path (RsvgDrawingCtx *ctx, const char *d)
}
else
render->outline = svp2;
rsvg_bpath_def_free (bpath_def);
}
void rsvg_art_render_image (RsvgDrawingCtx *ctx, GdkPixbuf * img,
void rsvg_art_render_image (RsvgDrawingCtx *ctx, const GdkPixbuf * img,
double x, double y, double w, double h)
{
int i, j;
......
......@@ -31,9 +31,9 @@
G_BEGIN_DECLS
void rsvg_art_render_path (RsvgDrawingCtx *ctx, const char *d);
void rsvg_art_svp_render_path (RsvgDrawingCtx *ctx, const char *d);
void rsvg_art_render_image (RsvgDrawingCtx *ctx, GdkPixbuf * img,
void rsvg_art_render_path (RsvgDrawingCtx *ctx, const RsvgBpathDef * path);
void rsvg_art_svp_render_path (RsvgDrawingCtx *ctx, const RsvgBpathDef * path);
void rsvg_art_render_image (RsvgDrawingCtx *ctx, const GdkPixbuf * img,
double x, double y, double w, double h);
G_END_DECLS
......
......@@ -67,7 +67,7 @@ rsvg_art_rect_clip_path(double x, double y, double w, double h, RsvgDrawingCtx *
save = ctx->render;
ctx->render = (RsvgRender *)asvpr;
asvpr->super.render_path(ctx, d->str);
rsvg_render_path (ctx, d->str);
ctx->render = save;
......
......@@ -22,25 +22,74 @@
Authors: Caleb Moore <c.moore@student.unsw.edu.au>
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "rsvg-art-composite.h"
#include "rsvg-art-draw.h"
#include "rsvg-art-render.h"
RsvgArtRender * rsvg_art_render_new(GdkPixbuf * pb)
static void
rsvg_art_pixels_destroy (guchar *pixels, gpointer data)
{
g_free (pixels);
}
static void
rsvg_art_render_free (RsvgRender * self)
{
RsvgArtRender * me = (RsvgArtRender *)self;
/* TODO */
g_free (me);
}
RsvgArtRender *
rsvg_art_render_new(int new_width, int new_height)
{
RsvgArtRender * output;
guint8 *pixels;
int rowstride;
rowstride = (new_width * 4 + 3) & ~3;
if (new_height <= 0 || rowstride > INT_MAX / new_height)
{
g_warning (_("rsvg_art_render_new: width too large"));
return NULL;
}
pixels = g_try_malloc (rowstride * new_height);
if (pixels == NULL)
{
g_warning (_("rsvg_art_render_new: dimensions too large"));
return NULL;
}
memset (pixels, 0, rowstride * new_height);
output = g_new(RsvgArtRender, 1);
output->super.free = rsvg_art_render_free;
output->super.render_path = rsvg_art_render_path;
output->super.render_image = rsvg_art_render_image;
output->super.pop_discrete_layer = rsvg_art_pop_discrete_layer;
output->super.push_discrete_layer = rsvg_art_push_discrete_layer;
output->super.add_clipping_rect = rsvg_art_add_clipping_rect;
output->pixbuf = gdk_pixbuf_new_from_data (pixels,
GDK_COLORSPACE_RGB,
TRUE, 8,
new_width, new_height,
rowstride,
rsvg_art_pixels_destroy,
NULL);
output->bbox.x0 = output->bbox.y0 = output->bbox.x1 = output->bbox.y1 = 0;
output->pixbuf = pb;
output->layers = NULL;
output->clippath = NULL;
return output;
}
......@@ -48,22 +97,36 @@ static void
bogus(RsvgDrawingCtx *ctx)
{
}
static void
image_bogus(RsvgDrawingCtx *ctx, GdkPixbuf *pb,
image_bogus(RsvgDrawingCtx *ctx, const GdkPixbuf *pb,
double x, double y, double w, double h)
{
}
static void
cr_bogus(RsvgDrawingCtx *ctx, double x, double y, double w, double h)
{
}
static void
rsvg_art_svp_render_free (RsvgRender * self)
{
RsvgArtSVPRender * me = (RsvgArtSVPRender *)self;
if (me->outline)
art_svp_free (me->outline);
g_free (me);
}
RsvgArtSVPRender * rsvg_art_svp_render_new()
RsvgArtSVPRender *
rsvg_art_svp_render_new(void)
{
RsvgArtSVPRender * output;
output = g_new(RsvgArtSVPRender, 1);
output->super.free = rsvg_art_svp_render_free;
output->super.render_path = rsvg_art_svp_render_path;
output->super.render_image = image_bogus;
output->super.pop_discrete_layer = bogus;
......
......@@ -48,7 +48,7 @@ struct RsvgArtSVPRender {
};
RsvgArtSVPRender * rsvg_art_svp_render_new(void);
RsvgArtRender * rsvg_art_render_new(GdkPixbuf *);
RsvgArtRender * rsvg_art_render_new(int new_width, int new_height);
G_END_DECLS
......
......@@ -34,10 +34,6 @@
#include <rsvg-art-render.h>
#include <rsvg-art-composite.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif /* M_PI */
#define PERFECTBLUR 0
/*************************************************************/
......
......@@ -40,10 +40,6 @@
Reference: SVG working draft 3 March 2000, section 8.
*/
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif /* M_PI */
typedef struct _RSVGParsePathCtx RSVGParsePathCtx;
struct _RSVGParsePathCtx {
......
......@@ -27,11 +27,13 @@
#define RSVG_PRIVATE_H
#include "rsvg.h"
#include "rsvg-bpath-util.h"
#include <libxml/SAX.h>
#include <libxml/xmlmemory.h>
#include <pango/pango.h>
#include <glib/gslist.h>
#include <math.h>
G_BEGIN_DECLS
......@@ -54,6 +56,15 @@ typedef struct _RsvgFilter RsvgFilter;
#define N_(X) X
#endif
#ifndef M_PI
# ifdef G_PI
# define M_PI G_PI
# else
# define M_PI 3.14159265358979323846
# endif /* G_PI */
#endif /* M_PI */
struct RsvgSaxHandler {
void (*free) (RsvgSaxHandler *self);
void (*start_element) (RsvgSaxHandler *self, const xmlChar *name, RsvgPropertyBag *atts);
......@@ -133,8 +144,10 @@ struct RsvgDrawingCtx {
/*Abstract base class for context for our backends (one as yet)*/
struct RsvgRender {
void (* render_path) (RsvgDrawingCtx *ctx, const char *d);
void (* render_image) (RsvgDrawingCtx *ctx, GdkPixbuf * pixbuf,
void (* free) (RsvgRender * self);
void (* render_path) (RsvgDrawingCtx *ctx, const RsvgBpathDef * path);
void (* render_image) (RsvgDrawingCtx *ctx, const GdkPixbuf * pixbuf,
double x, double y, double w, double h);
void (* pop_discrete_layer) (RsvgDrawingCtx *ctx);
void (* push_discrete_layer) (RsvgDrawingCtx *ctx);
......@@ -225,6 +238,7 @@ void rsvg_push_discrete_layer (RsvgDrawingCtx *ctx);
void rsvg_render_path (RsvgDrawingCtx *ctx, const char *d);
void rsvg_render_image (RsvgDrawingCtx *ctx, GdkPixbuf * pb,
double x, double y, double w, double h);
void rsvg_render_free (RsvgRender * render);
void rsvg_add_clipping_rect (RsvgDrawingCtx *ctx, double x, double y,
double w, double h);
......
......@@ -38,10 +38,6 @@
/* 4/3 * (1-cos 45ƒ)/sin 45ƒ = 4/3 * sqrt(2) - 1 */
#define RSVG_ARC_MAGIC ((double) 0.5522847498)
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif /* M_PI */
static void
rsvg_defs_drawable_path_free (RsvgDefVal *self)
{
......
......@@ -83,12 +83,6 @@ rsvg_ctx_free_helper (gpointer key, gpointer value, gpointer user_data)
g_free (entval);
}
static void
rsvg_pixmap_destroy (guchar *pixels, gpointer data)
{
g_free (pixels);
}
static void
rsvg_start_svg (RsvgHandle *ctx, RsvgPropertyBag *atts)
{
......@@ -1660,40 +1654,16 @@ rsvg_handle_new (void)
static RsvgDrawingCtx *
rsvg_new_drawing_ctx(RsvgHandle * handle)
{
art_u8 *pixels;
int rowstride, new_width, new_height;
RsvgDrawingCtx * draw;
draw = g_new(RsvgDrawingCtx, 1);
draw->state = NULL;
/* should this be G_ALLOC_ONLY? */
draw->state_allocator = g_mem_chunk_create (RsvgState, 256, G_ALLOC_AND_FREE);
new_width = handle->new_width;
new_height = handle->new_height;
rowstride = (new_width * 4 + 3) & ~3;
if (new_height <= 0 || rowstride > INT_MAX / new_height)
{
/* FIXME: GError here? */
g_warning (_("rsvg_start_svg: width too large"));
return NULL;
}
pixels = g_try_malloc (rowstride * new_height);
if (pixels == NULL)
{
/* FIXME: GError here? */
g_warning (_("rsvg_start_svg: dimensions too large"));
return NULL;
}
memset (pixels, 0, rowstride * new_height);
draw->render = (RsvgRender *) rsvg_art_render_new
(gdk_pixbuf_new_from_data (pixels,
GDK_COLORSPACE_RGB,
TRUE, 8,
new_width, new_height,
rowstride,
rsvg_pixmap_destroy,
NULL));
draw->render = (RsvgRender *) rsvg_art_render_new (handle->new_width, handle->new_height);
draw->defs = handle->defs;
draw->base_uri = g_strdup(handle->base_uri);
draw->dpi_x = handle->dpi_x;
......@@ -1992,24 +1962,42 @@ rsvg_pop_discrete_layer(RsvgDrawingCtx *ctx)
{
ctx->render->pop_discrete_layer(ctx);
}
void
rsvg_push_discrete_layer (RsvgDrawingCtx *ctx)
{
ctx->render->push_discrete_layer(ctx);
}
void
rsvg_render_path (RsvgDrawingCtx *ctx, const char *d)
{
ctx->render->render_path(ctx, d);
/* todo: store and use the bpath higher up */
RsvgBpathDef * bpath_def;
bpath_def = rsvg_parse_path (d);
rsvg_bpath_def_art_finish (bpath_def);
ctx->render->render_path(ctx, bpath_def);
rsvg_bpath_def_free (bpath_def);
}
void
rsvg_render_image (RsvgDrawingCtx *ctx, GdkPixbuf * pb,
double x, double y, double w, double h)
{
ctx->render->render_image(ctx, pb, x, y, w, h);
}
void
rsvg_add_clipping_rect (RsvgDrawingCtx *ctx, double x, double y, double w, double h)
{
ctx->render->add_clipping_rect(ctx, x, y, w, h);
}
void
rsvg_render_free (RsvgRender * render)
{
render->free (render);
}
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