]> granicus.if.org Git - graphviz/commitdiff
fix bug#1317 - we now keep a maximum of 50 image files open
authorellson <devnull@localhost>
Sat, 15 Mar 2008 23:19:31 +0000 (23:19 +0000)
committerellson <devnull@localhost>
Sat, 15 Mar 2008 23:19:31 +0000 (23:19 +0000)
added support for CAIRO_FORMAT_RGB24 format in png:ps:cairo loader  (for -Tps)

plugin/core/gvloadimage_core.c
plugin/gd/gvloadimage_gd.c
plugin/pango/gvloadimage_pango.c
plugin/rsvg/gvloadimage_rsvg.c

index 4b76b8b2a9e68a0f5ba56af86a3b1edb28b0e9fd..c66d8e8a8d579e54d66e282762daf4b3e351cb85 100644 (file)
@@ -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, "<image xlink:href=\"");
     gvdevice_fputs(job, us->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);
index 3cab9e3e5bf1e31ad6052433e3a2c49c5df222c0..ececad48c535eae865b9730154f1b17a88c33811 100644 (file)
@@ -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);
 }
index 9db827da7aef523fa30b3696bfab4e1a041971e6..df600afec4c3967822f801fbce1fdb565bb45a0f 100644 (file)
@@ -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);
index b3a3d1b96b598b0ddeb11aa62ef1f96751f8bac8..962064b74258ec5995fdbdd57b78f152d54e85c9 100644 (file)
@@ -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;