]> granicus.if.org Git - graphviz/commitdiff
jpeg loading using gdk plugin (was gdk_pixbuf) basically working
authorJohn Ellson <john.ellson@comcast.net>
Sun, 20 Oct 2013 18:18:26 +0000 (14:18 -0400)
committerJohn Ellson <john.ellson@comcast.net>
Sun, 20 Oct 2013 18:18:26 +0000 (14:18 -0400)
configure.ac
graphviz.spec.in
plugin/Makefile.am
plugin/gdk/Makefile.am [new file with mode: 0644]
plugin/gdk/Makefile.old [moved from plugin/gdk_pixbuf/Makefile.old with 52% similarity]
plugin/gdk/gvloadimage_gdk.c [moved from plugin/gdk_pixbuf/gvloadimage_gdk_pixbuf.c with 75% similarity]
plugin/gdk_pixbuf/Makefile.am [deleted file]
plugin/gdk_pixbuf/gvdevice_gdk_pixbuf.c [deleted file]
plugin/gdk_pixbuf/gvplugin_gdk_pixbuf.c [deleted file]

index bf738fbbff1f9528aef0e3fc93920ed6335eee10..d5eba29093b820c2bd5a288e1b6c1a2d4745f87d 100644 (file)
@@ -2375,6 +2375,28 @@ if test "x$use_fontconfig" = "xYes"; then
 fi
 AM_CONDITIONAL(WITH_FONTCONFIG, [test "x$use_fontconfig" = "xYes"])
 
+dnl -----------------------------------
+dnl INCLUDES and LIBS for GDK
+
+AC_ARG_WITH(gdk,
+  [AS_HELP_STRING([--with-gdk=yes],[gdklibrary])],
+  [], [with_gdk=yes])
+
+if test "x$with_gdk" != "xyes"; then
+  use_gdk="No (disabled)"
+else
+  PKG_CHECK_MODULES(GDK, [gdk-2.0],[
+    use_gdk="Yes"
+    AC_DEFINE_UNQUOTED(HAVE_GDK,1,
+      [Define if you have the gdk library])
+    AC_SUBST([GDK_CFLAGS])
+    AC_SUBST([GDK_LIBS])
+  ],[
+    use_gdk_pixbuf="No (gdk library not available)"
+  ])
+fi
+AM_CONDITIONAL(WITH_GDK, [test "x$use_gdk" = "xYes"])
+
 dnl -----------------------------------
 dnl INCLUDES and LIBS for GDK_PIXBUF.
 
@@ -3178,7 +3200,7 @@ AC_CONFIG_FILES(Makefile
        plugin/core/Makefile
        plugin/devil/Makefile
        plugin/gd/Makefile
-       plugin/gdk_pixbuf/Makefile
+       plugin/gdk/Makefile
        plugin/gdiplus/Makefile
        plugin/glitz/Makefile
        plugin/gs/Makefile
@@ -3318,6 +3340,7 @@ echo "  core:          Yes (always enabled)"
 echo "  devil:         $use_devil"
 echo "  gd:            $use_gd"
 echo "  gdiplus:       $use_gdiplus"
+echo "  gdk:           $use_gdk"
 echo "  gdk_pixbuf:    $use_gdk_pixbuf"
 echo "  ghostscript:   $use_ghostscript"
 echo "  glitz:         $use_glitz"
index 8cdfb5618a419eaaddff98789950f9cb3744ecbb..80c6922e441e5bbcb3db5553ddfc46e012ae9115 100644 (file)
@@ -30,7 +30,7 @@ Prefix: /usr
 # Available features are:
 #    SHARP GHOSTSCRIPT GUILE _IO JAVA LUA OCAML ORTHO PERL PHP
 #    PYTHON RUBY R_LANG TCL IPSEPCOLA MYLIBGD PANGOCAIRO RSVG
-#    GTK GLITZ SMYRNA DEVIL MING GDK_PIXBUF _QT WEBP
+#    GTK GLITZ SMYRNA DEVIL MING GDK _QT WEBP
 
 # SuSE uses a different mechanism to generate BuildRequires
 # norootforbuild
@@ -88,7 +88,7 @@ BuildRequires: ocaml
 BuildRequires: php-devel
 %define MYLIBGD 0
 BuildRequires: gd gd-devel
-%define GDK_PIXBUF 1
+%define GDK 1
 %define GHOSTSCRIPT 1
 BuildRequires: ghostscript-devel
 %define POPPLER 1
@@ -140,7 +140,7 @@ BuildRequires: DevIL-devel
 BuildRequires: gts-devel
 %define LASI 1
 BuildRequires: lasi-devel
-%define GDK_PIXBUF 1
+%define GDK 1
 %define IPSEPCOLA 1
 %define ORTHO 1
 %define GTK 1
@@ -359,8 +359,8 @@ LD_LIBRARY_PATH=$RPM_INSTALL_PREFIX0/%{_lib} $RPM_INSTALL_PREFIX0/bin/dot -c
 %if 0%{?LASI}
 %{_libdir}/graphviz/libgvplugin_lasi.so.*
 %endif
-%if 0%{?GDK_PIXBUF}
-%{_libdir}/graphviz/libgvplugin_gdk_pixbuf.so.*
+%if 0%{?GDK}
+%{_libdir}/graphviz/libgvplugin_gdk.so.*
 %endif
 %if 0%{?GTK}
 %{_libdir}/graphviz/libgvplugin_gtk.so.*
@@ -857,7 +857,7 @@ CFLAGS="$RPM_OPT_FLAGS" \
         --enable-tcl%{!?TCL:=no} \
         --with%{!?DEVIL:out}-devil \
         --with%{!?WEBP:out}-webp \
-        --with%{!?GDK_PIXBUF:out}-gdk-pixbuf \
+        --with%{!?GDK:out}-gdk \
         --with%{!?GHOSTSCRIPT:out}-ghostscript \
         --with%{!?GLITZ:out}-glitz \
         --with%{!?IPSEPCOLA:out}-ipsepcola \
index 111b3747b47d8c23cde9340297a9eba4e2831f30..ee8292a5e94a19ebb85bd2e1a2c3db23b6450bb9 100644 (file)
@@ -1,6 +1,6 @@
 # $Id$ $Revision$
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = core devil gd gdk_pixbuf gdiplus glitz gs gtk lasi ming pango quartz rsvg visio xlib dot_layout neato_layout webp poppler
+SUBDIRS = core devil gd gdk gdiplus glitz gs gtk lasi ming pango quartz rsvg visio xlib dot_layout neato_layout webp poppler
 
 EXTRA_DIST = Makefile.old
diff --git a/plugin/gdk/Makefile.am b/plugin/gdk/Makefile.am
new file mode 100644 (file)
index 0000000..0a5472a
--- /dev/null
@@ -0,0 +1,45 @@
+# $Id$ $Revision$
+## Process this file with automake to produce Makefile.in
+
+AM_CPPFLAGS = \
+       -I$(top_srcdir) \
+       -I$(top_srcdir)/lib/common \
+       -I$(top_srcdir)/lib/pathplan \
+       -I$(top_srcdir)/lib/gvc \
+       -I$(top_srcdir)/lib/cgraph \
+       -I$(top_srcdir)/lib/cdt \
+       $(PANGOCAIRO_CFLAGS) $(GDK_PIXBUF_CFLAGS) $(GDK_CFLAGS)
+
+if WITH_PANGOCAIRO
+if WITH_GDK
+if WITH_GDK_PIXBUF
+noinst_LTLIBRARIES = libgvplugin_gdk_C.la
+if WITH_WIN32
+lib_LTLIBRARIES = libgvplugin_gdk.la
+else
+pkglib_LTLIBRARIES = libgvplugin_gdk.la
+endif
+endif
+endif
+endif
+
+libgvplugin_gdk_C_la_SOURCES = \
+       gvplugin_gdk.c \
+       gvdevice_gdk.c \
+       gvloadimage_gdk.c
+
+libgvplugin_gdk_la_LDFLAGS = -version-info @GVPLUGIN_VERSION_INFO@
+libgvplugin_gdk_la_SOURCES = $(libgvplugin_gdk_C_la_SOURCES)
+libgvplugin_gdk_la_LIBADD = \
+       $(top_builddir)/lib/gvc/libgvc.la @GDK_PIXBUF_LIBS@ @PANGOCAIRO_LIBS@ @GDK_LIBS@
+       
+if WITH_WIN32
+libgvplugin_gdk_la_LDFLAGS += -no-undefined
+endif
+
+if WITH_DARWIN9
+libgvplugin_gdk_la_LDFLAGS += -Wl,-exported_symbol,_gvplugin_gdk_LTX_library
+endif
+
+EXTRA_DIST = Makefile.old
+
similarity index 52%
rename from plugin/gdk_pixbuf/Makefile.old
rename to plugin/gdk/Makefile.old
index 651342ddca2c481825c33cdc96d6ee8dda0cead3..8a2053e63cacabe9ad78c9bb3f21248eacd01c91 100644 (file)
@@ -1,4 +1,4 @@
-all:   libgvplugin_gdk_pixbuf.a
+all:   libgvplugin_gdk.a
 ROOT=../..
 include $(ROOT)/Config.mk
 include $(ROOT)/makearch/$(ARCH)
@@ -13,16 +13,16 @@ INCS =  -I. \
 
 DEFINES = -DHAVE_CONFIG_H
 
-OBJS = gvformatter_gdk_pixbuf.o gvplugin_gdk_pixbuf.o
+OBJS = gvformatter_gdk.o gvplugin_gdk.o
 
-libgvplugin_gdk_pixbuf.a : $(OBJS)
-       $(RM) libgvplugin_gdk_pixbuf.a
-       $(AR) cr libgvplugin_gdk_pixbuf.a $(OBJS)
-       $(RANLIB) libgvplugin_gdk_pixbuf.a
+libgvplugin_gdk.a : $(OBJS)
+       $(RM) libgvplugin_gdk.a
+       $(AR) cr libgvplugin_gdk.a $(OBJS)
+       $(RANLIB) libgvplugin_gdk.a
 
-install: libgvplugin_gdk_pixbuf.a
+install: libgvplugin_gdk.a
        $(MKPATH) $(LIBDIR)
-       $(INSTALL) libgvplugin_gdk_pixbuf.a $(LIBDIR)
+       $(INSTALL) libgvplugin_gdk.a $(LIBDIR)
 
 clean:
        $(RM) core *.o
similarity index 75%
rename from plugin/gdk_pixbuf/gvloadimage_gdk_pixbuf.c
rename to plugin/gdk/gvloadimage_gdk.c
index 2bf8d3262488e2f189e0eb449360241afd3bedb9..bd3f285fc6746452d59d8693d05887f4054c86cf 100644 (file)
@@ -54,12 +54,12 @@ reader (void *closure, unsigned char *data, unsigned int length)
 }
 #endif
 
-static void gdk_pixbuf_freeimage(usershape_t *us)
+static void gdk_freeimage(usershape_t *us)
 {
     g_object_unref((GdkPixbuf*)(us->data));
 }
 
-static GdkPixbuf* gdk_pixbuf_loadimage(GVJ_t * job, usershape_t *us)
+static GdkPixbuf* gdk_loadimage(GVJ_t * job, usershape_t *us)
 {
     GdkPixbuf *image = NULL;
 
@@ -68,7 +68,7 @@ static GdkPixbuf* gdk_pixbuf_loadimage(GVJ_t * job, usershape_t *us)
     assert(us->name);
 
     if (us->data) {
-        if (us->datafree == gdk_pixbuf_freeimage)
+        if (us->datafree == gdk_freeimage)
              image = (GdkPixbuf*)(us->data); /* use cached data */
         else {
              us->datafree(us);        /* free incompatible cache data */
@@ -93,19 +93,19 @@ static GdkPixbuf* gdk_pixbuf_loadimage(GVJ_t * job, usershape_t *us)
         }
         if (image) {
             us->data = (void*)image;
-            us->datafree = gdk_pixbuf_freeimage;
+            us->datafree = gdk_freeimage;
         }
        gvusershape_file_release(us);
     }
     return image;
 }
 
-static void gdk_pixbuf_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
+static void gdk_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
 {
     cairo_t *cr = (cairo_t *) job->context; /* target context */
     GdkPixbuf *image;
 
-    image = gdk_pixbuf_loadimage(job, us);
+    image = gdk_loadimage(job, us);
     if (image) {
         cairo_save(cr);
         cairo_translate(cr,
@@ -120,22 +120,22 @@ static void gdk_pixbuf_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, boo
     }
 }
 
-static gvloadimage_engine_t engine_gdk_pixbuf = {
-    gdk_pixbuf_loadimage_cairo
+static gvloadimage_engine_t engine_gdk = {
+    gdk_loadimage_cairo
 };
 
 #endif
 
-gvplugin_installed_t gvloadimage_gdk_pixbuf_types[] = {
+gvplugin_installed_t gvloadimage_gdk_types[] = {
 #ifdef HAVE_PANGOCAIRO
-    {FORMAT_BMP_CAIRO, "bmp:cairo", 1, &engine_gdk_pixbuf, NULL},
-    {FORMAT_JPEG_CAIRO, "jpe:cairo", 2, &engine_gdk_pixbuf, NULL},
-    {FORMAT_JPEG_CAIRO, "jpg:cairo", 2, &engine_gdk_pixbuf, NULL},
-    {FORMAT_JPEG_CAIRO, "jpeg:cairo", 2, &engine_gdk_pixbuf, NULL},
-    {FORMAT_PNG_CAIRO, "png:cairo", -1, &engine_gdk_pixbuf, NULL},
-//    {FORMAT_ICO_CAIRO, "ico:cairo", -99, &engine_gdk_pixbuf, NULL},
-//    {FORMAT_TIFF_CAIRO, "tif:cairo", -99, &engine_gdk_pixbuf, NULL},
-//    {FORMAT_TIFF_CAIRO, "tiff`:cairo", -99, &engine_gdk_pixbuf, NULL},
+    {FORMAT_BMP_CAIRO, "bmp:cairo", 1, &engine_gdk, NULL},
+    {FORMAT_JPEG_CAIRO, "jpe:cairo", 2, &engine_gdk, NULL},
+    {FORMAT_JPEG_CAIRO, "jpg:cairo", 2, &engine_gdk, NULL},
+    {FORMAT_JPEG_CAIRO, "jpeg:cairo", 2, &engine_gdk, NULL},
+    {FORMAT_PNG_CAIRO, "png:cairo", -1, &engine_gdk, NULL},
+//    {FORMAT_ICO_CAIRO, "ico:cairo", -99, &engine_gdk, NULL},
+//    {FORMAT_TIFF_CAIRO, "tif:cairo", -99, &engine_gdk, NULL},
+//    {FORMAT_TIFF_CAIRO, "tiff`:cairo", -99, &engine_gdk, NULL},
 #endif
     {0, NULL, 0, NULL, NULL}
 };
diff --git a/plugin/gdk_pixbuf/Makefile.am b/plugin/gdk_pixbuf/Makefile.am
deleted file mode 100644 (file)
index 8796a7c..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-# $Id$ $Revision$
-## Process this file with automake to produce Makefile.in
-
-AM_CPPFLAGS = \
-       -I$(top_srcdir) \
-       -I$(top_srcdir)/lib/common \
-       -I$(top_srcdir)/lib/pathplan \
-       -I$(top_srcdir)/lib/gvc \
-       -I$(top_srcdir)/lib/cgraph \
-       -I$(top_srcdir)/lib/cdt \
-       $(PANGOCAIRO_CFLAGS) $(GDK_PIXBUF_CFLAGS) $(GTK_CFLAGS)
-
-if WITH_PANGOCAIRO
-if WITH_GDK_PIXBUF
-noinst_LTLIBRARIES = libgvplugin_gdk_pixbuf_C.la
-if WITH_WIN32
-lib_LTLIBRARIES = libgvplugin_gdk_pixbuf.la
-else
-pkglib_LTLIBRARIES = libgvplugin_gdk_pixbuf.la
-endif
-endif
-endif
-
-libgvplugin_gdk_pixbuf_C_la_SOURCES = \
-       gvplugin_gdk_pixbuf.c \
-       gvdevice_gdk_pixbuf.c \
-       gvloadimage_gdk_pixbuf.c
-
-libgvplugin_gdk_pixbuf_la_LDFLAGS = -version-info @GVPLUGIN_VERSION_INFO@
-libgvplugin_gdk_pixbuf_la_SOURCES = $(libgvplugin_gdk_pixbuf_C_la_SOURCES)
-libgvplugin_gdk_pixbuf_la_LIBADD = \
-       $(top_builddir)/lib/gvc/libgvc.la @GDK_PIXBUF_LIBS@
-       
-if WITH_WIN32
-libgvplugin_gdk_pixbuf_la_LDFLAGS += -no-undefined
-endif
-
-if WITH_DARWIN9
-libgvplugin_gdk_pixbuf_la_LDFLAGS += -Wl,-exported_symbol,_gvplugin_gdk_pixbuf_LTX_library
-endif
-
-EXTRA_DIST = Makefile.old
-
diff --git a/plugin/gdk_pixbuf/gvdevice_gdk_pixbuf.c b/plugin/gdk_pixbuf/gvdevice_gdk_pixbuf.c
deleted file mode 100644 (file)
index 7ce20ae..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/* $Id$ $Revision$ */
-/* vim:set shiftwidth=4 ts=8: */
-
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: See CVS logs. Details at http://www.graphviz.org/
- *************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gvplugin_device.h"
-#include "gvio.h"
-#ifdef HAVE_PANGOCAIRO
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-typedef enum {
-       FORMAT_BMP,
-       FORMAT_ICO,
-       FORMAT_JPEG,
-       FORMAT_PNG,
-       FORMAT_TIFF,
-    } format_type;
-
-/* 
- * Does an in-place conversion of a CAIRO ARGB32 image to GDK RGBA
- */
-static void
-argb2rgba ( unsigned int width, unsigned int height, char *data)
-{
-/* define indexes to color bytes in each format */
-#define Ba 0
-#define Ga 1
-#define Ra 2
-#define Aa 3
-
-#define Rb 0
-#define Gb 1
-#define Bb 2
-#define Ab 3
-
-    unsigned int x, y;
-
-    for (y = 0; y < height; y++) {
-        for (x = 0; x < width; x++) {
-            /* swap red and blue */
-            unsigned char r = data[Ra];
-            data[Bb] = data[Ba];
-           data[Rb] = r;
-            data += 4;
-        }
-    }
-}
-
-static gboolean
-writer ( const gchar *buf, gsize count, GError **error, gpointer data)
-{
-    if (count == gvwrite((GVJ_t *)data, buf, count))
-        return TRUE;
-    return FALSE;
-}
-
-static void gdk_pixbuf_format(GVJ_t * job)
-{
-    char *format_str = "";
-    GdkPixbuf *pixbuf;
-
-    switch (job->device.id) {
-    case FORMAT_BMP:
-       format_str = "bmp";
-       break;
-    case FORMAT_ICO:
-       format_str = "ico";
-       break;
-    case FORMAT_JPEG:
-       format_str = "jpeg";
-       break;
-    case FORMAT_PNG:
-       format_str = "png";
-       break;
-    case FORMAT_TIFF:
-       format_str = "tiff";
-       break;
-    }
-
-    argb2rgba(job->width, job->height, job->imagedata);
-
-    pixbuf = gdk_pixbuf_new_from_data(
-                (unsigned char*)(job->imagedata), // data
-                GDK_COLORSPACE_RGB,     // colorspace
-                TRUE,                   // has_alpha
-                8,                      // bits_per_sample
-                job->width,             // width
-                job->height,            // height
-                4 * job->width,         // rowstride
-                NULL,                   // destroy_fn
-                NULL                    // destroy_fn_data
-               );
-
-    gdk_pixbuf_save_to_callback(pixbuf, writer, job, format_str, NULL, NULL);
-
-    gdk_pixbuf_unref(pixbuf);
-}
-
-static gvdevice_engine_t gdk_pixbuf_engine = {
-    NULL,              /* gdk_pixbuf_initialize */
-    gdk_pixbuf_format,
-    NULL,              /* gdk_pixbuf_finalize */
-};
-
-static gvdevice_features_t device_features_gdk_pixbuf = {
-    GVDEVICE_BINARY_FORMAT
-      | GVDEVICE_DOES_TRUECOLOR,/* flags */
-    {0.,0.},                    /* default margin - points */
-    {0.,0.},                    /* default page width, height - points */
-    {96.,96.},                  /* dpi */
-};
-#endif
-
-gvplugin_installed_t gvdevice_gdk_pixbuf_types[] = {
-#ifdef HAVE_PANGOCAIRO
-    {FORMAT_BMP, "bmp:cairo", 4, &gdk_pixbuf_engine, &device_features_gdk_pixbuf},
-    {FORMAT_ICO, "ico:cairo", 4, &gdk_pixbuf_engine, &device_features_gdk_pixbuf},
-    {FORMAT_JPEG, "jpe:cairo", 4, &gdk_pixbuf_engine, &device_features_gdk_pixbuf},
-    {FORMAT_JPEG, "jpeg:cairo", 4, &gdk_pixbuf_engine, &device_features_gdk_pixbuf},
-    {FORMAT_JPEG, "jpg:cairo", 4, &gdk_pixbuf_engine, &device_features_gdk_pixbuf},
-    {FORMAT_PNG, "png:cairo", 4, &gdk_pixbuf_engine, &device_features_gdk_pixbuf},
-    {FORMAT_TIFF, "tif:cairo", 4, &gdk_pixbuf_engine, &device_features_gdk_pixbuf},
-    {FORMAT_TIFF, "tiff:cairo", 4, &gdk_pixbuf_engine, &device_features_gdk_pixbuf},
-#endif
-    {0, NULL, 0, NULL, NULL}
-};
diff --git a/plugin/gdk_pixbuf/gvplugin_gdk_pixbuf.c b/plugin/gdk_pixbuf/gvplugin_gdk_pixbuf.c
deleted file mode 100644 (file)
index 51cb491..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* $Id$ $Revision$ */
-/* vim:set shiftwidth=4 ts=8: */
-
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: See CVS logs. Details at http://www.graphviz.org/
- *************************************************************************/
-
-#include "gvplugin.h"
-
-extern gvplugin_installed_t gvdevice_gdk_pixbuf_types[];
-extern gvplugin_installed_t gvloadimage_gdk_pixbuf_types[];
-
-static gvplugin_api_t apis[] = {
-    {API_device, gvdevice_gdk_pixbuf_types},
-    {API_loadimage, gvloadimage_gdk_pixbuf_types},
-    {(api_t)0, 0},
-};
-
-gvplugin_library_t gvplugin_gdk_pixbuf_LTX_library = { "gdk_pixbuf", apis };