From: ellson Date: Sat, 15 Mar 2008 23:19:31 +0000 (+0000) Subject: fix bug#1317 - we now keep a maximum of 50 image files open X-Git-Tag: LAST_LIBGRAPH~32^2~4494 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=afabf38403a1b59278d3193e802118e4c395ceca;p=graphviz fix bug#1317 - we now keep a maximum of 50 image files open added support for CAIRO_FORMAT_RGB24 format in png:ps:cairo loader (for -Tps) --- diff --git a/plugin/core/gvloadimage_core.c b/plugin/core/gvloadimage_core.c index 4b76b8b2a..c66d8e8a8 100644 --- a/plugin/core/gvloadimage_core.c +++ b/plugin/core/gvloadimage_core.c @@ -47,7 +47,6 @@ static void core_loadimage_svg(GVJ_t * job, usershape_t *us, boxf b, boolean fil assert(job); assert(us); assert(us->name); - assert(us->f); gvdevice_fputs(job, "name); @@ -89,7 +88,6 @@ static void core_loadimage_fig(GVJ_t * job, usershape_t *us, boxf bf, boolean fi assert(job); assert(us); assert(us->name); - assert(us->f); BF2B(bf, b); @@ -121,7 +119,6 @@ static void core_loadimage_vrml(GVJ_t * job, usershape_t *us, boxf b, boolean fi assert(us); assert(us->name); - assert(us->f); n = job->obj->u.n; assert(n); @@ -135,8 +132,6 @@ static void core_loadimage_vrml(GVJ_t * job, usershape_t *us, boxf b, boolean fi fprintf(out, " texture ImageTexture { url \"%s\" }\n", us->name); fprintf(out, " }\n"); fprintf(out, "}\n"); - - } static void ps_freeimage(usershape_t *us) @@ -156,7 +151,6 @@ static void core_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean fill assert(job); assert(us); assert(us->name); - assert(us->f); out = job->output_file; assert(out); @@ -171,10 +165,12 @@ static void core_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean fill } if (!us->data) { /* read file into cache */ - int fd = fileno(us->f); + int fd; struct stat statbuf; - fseek(us->f, 0, SEEK_SET); + if (!gvusershape_file_access(us)) + return; + fd = fileno(us->f); switch (us->type) { case FT_PS: case FT_EPS: @@ -193,6 +189,7 @@ static void core_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean fill } if (us->data) us->datafree = ps_freeimage; + gvusershape_file_release(us); } if (us->data) { @@ -217,7 +214,6 @@ static void core_loadimage_pslib(GVJ_t * job, usershape_t *us, boxf b, boolean f assert(job); assert(us); assert(us->name); - assert(!(us->f)); out = job->output_file; assert(out); diff --git a/plugin/gd/gvloadimage_gd.c b/plugin/gd/gvloadimage_gd.c index 3cab9e3e5..ececad48c 100644 --- a/plugin/gd/gvloadimage_gd.c +++ b/plugin/gd/gvloadimage_gd.c @@ -43,7 +43,6 @@ static gdImagePtr gd_loadimage(GVJ_t * job, usershape_t *us) assert(job); assert(us); assert(us->name); - assert(us->f); if (us->data) { if (us->datafree != gd_freeimage) { @@ -53,7 +52,8 @@ static gdImagePtr gd_loadimage(GVJ_t * job, usershape_t *us) } } if (!us->data) { /* read file into cache */ - fseek(us->f, 0, SEEK_SET); + if (!gvusershape_file_access(us)) + return; switch (us->type) { #if 0 case FT_GD: @@ -95,6 +95,8 @@ static gdImagePtr gd_loadimage(GVJ_t * job, usershape_t *us) } if (us->data) us->datafree = gd_freeimage; + + gvusershape_file_release(us); } return (gdImagePtr)(us->data); } diff --git a/plugin/pango/gvloadimage_pango.c b/plugin/pango/gvloadimage_pango.c index 9db827da7..df600afec 100644 --- a/plugin/pango/gvloadimage_pango.c +++ b/plugin/pango/gvloadimage_pango.c @@ -50,7 +50,6 @@ static cairo_surface_t* cairo_loadimage(GVJ_t * job, usershape_t *us) assert(job); assert(us); assert(us->name); - assert(us->f); if (us->data) { if (us->datafree == cairo_freeimage) @@ -61,7 +60,8 @@ static cairo_surface_t* cairo_loadimage(GVJ_t * job, usershape_t *us) } } if (!surface) { /* read file into cache */ - fseek(us->f, 0, SEEK_SET); + if (!gvusershape_file_access(us)) + return NULL; switch (us->type) { #ifdef CAIRO_HAS_PNG_FUNCTIONS case FT_PNG: @@ -76,6 +76,7 @@ static cairo_surface_t* cairo_loadimage(GVJ_t * job, usershape_t *us) us->data = (void*)surface; us->datafree = cairo_freeimage; } + gvusershape_file_release(us); } return surface; } @@ -100,12 +101,17 @@ static void pango_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, boolean static void pango_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean filled) { cairo_surface_t *surface; /* source surface */ + cairo_format_t format; FILE *out = job->output_file; int X, Y, x, y, stride; unsigned char *data, *ix, alpha, red, green, blue; surface = cairo_loadimage(job, us); - if (surface && (cairo_image_surface_get_format(surface) == CAIRO_FORMAT_ARGB32)) { + if (surface) { + format = cairo_image_surface_get_format(surface); + if ((format != CAIRO_FORMAT_ARGB32) && (format != CAIRO_FORMAT_RGB24)) + return; + X = cairo_image_surface_get_width(surface); Y = cairo_image_surface_get_height(surface); stride = cairo_image_surface_get_stride(surface); diff --git a/plugin/rsvg/gvloadimage_rsvg.c b/plugin/rsvg/gvloadimage_rsvg.c index b3a3d1b96..962064b74 100644 --- a/plugin/rsvg/gvloadimage_rsvg.c +++ b/plugin/rsvg/gvloadimage_rsvg.c @@ -59,7 +59,6 @@ static RsvgHandle* gvloadimage_rsvg_load(GVJ_t * job, usershape_t *us) assert(job); assert(us); assert(us->name); - assert(us->f); if (us->data) { if (us->datafree == gvloadimage_rsvg_free) @@ -72,6 +71,8 @@ static RsvgHandle* gvloadimage_rsvg_load(GVJ_t * job, usershape_t *us) } if (!rsvgh) { /* read file into cache */ + if (!gvusershape_file_access(us)) + return; switch (us->type) { case FT_SVG: @@ -127,6 +128,8 @@ static RsvgHandle* gvloadimage_rsvg_load(GVJ_t * job, usershape_t *us) us->data = (void*)rsvgh; us->datafree = gvloadimage_rsvg_free; } + + gvusershape_file_release(us); } return rsvgh;