]> granicus.if.org Git - graphviz/commitdiff
split output "device" plugin from renderer plugin so that we can use
authorellson <devnull@localhost>
Tue, 21 Jun 2005 19:49:11 +0000 (19:49 +0000)
committerellson <devnull@localhost>
Tue, 21 Jun 2005 19:49:11 +0000 (19:49 +0000)
    cairo for png output without loading x11

14 files changed:
lib/common/emit.c
lib/common/input.c
lib/common/types.h
lib/gvc/Makefile.am
lib/gvc/Makefile.old
lib/gvc/gvc.h
lib/gvc/gvcint.h
lib/gvc/gvdevice.c [new file with mode: 0644]
lib/gvc/gvplugin.h
lib/gvc/gvplugin_device.h [new file with mode: 0644]
lib/gvc/gvplugin_render.h
lib/gvc/gvplugin_textlayout.h
lib/gvc/gvrender.c
lib/gvc/gvtextlayout.c

index eab23b82ec1b08e9db7d56eea7dd85a93d364c39..6e10e3989d5cc4f4ec1d527f1cd674e15b7ef34c 100644 (file)
@@ -1337,6 +1337,7 @@ void emit_jobs_eof(GVC_t * gvc)
         if (job->output_file) {
            if (gvc->viewNum > 0) {
                gvrender_end_job(job);
+               gvdevice_end_job(job);
                emit_once_reset();
                gvc->viewNum = 0;
            }
@@ -1614,6 +1615,7 @@ static void emit_job(GVJ_t * job, graph_t * g)
     init_job_viewport(job, g);
     init_job_pagination(job, g);
 
+    gvdevice_begin_job(job);
     gvrender_begin_job(job);
 
     switch (job->output_lang) {
@@ -1773,12 +1775,12 @@ void emit_jobs (GVC_t * gvc, graph_t * g)
         
        if (gvc->active_jobs && strcmp(job->output_langname,gvc->active_jobs->output_langname) != 0) {
            /* finalize previous jobs */
-           gvrender_finalize(gvc);
+           gvdevice_finalize(gvc);
            /* clear active list */
            gvc->active_jobs = NULL;
         }
        if (! gvc->active_jobs)
-           gvrender_initialize(gvc);
+           gvdevice_initialize(gvc);
 
        /* insert job in active list */
        job->next_active = gvc->active_jobs;
index 49e2091d2790792836192b231d820ef336c1e338..9e020cef6b74dab853b887703a3a7efef04cae16 100644 (file)
@@ -746,7 +746,7 @@ void do_graph_label(graph_t * sg)
 void dotneato_terminate(GVC_t * gvc)
 {
     if (gvc->active_jobs)
-       gvrender_finalize(gvc);
+       gvdevice_finalize(gvc);
     emit_jobs_eof(gvc);
     exit(graphviz_errors + agerrors());
 }
index ebf837e874e1e279ec1da199227afa0c97e2a221..92cf0137086d4e94ea2bde0847a8fb531f96f547 100644 (file)
@@ -35,10 +35,10 @@ extern "C" {
 
     typedef struct GVC_s GVC_t;
     typedef struct GVJ_s GVJ_t;
+    typedef struct gvdevice_engine_s gvdevice_engine_t;
     typedef struct gvrender_engine_s gvrender_engine_t;
     typedef struct gvlayout_engine_s gvlayout_engine_t;
-    typedef struct gvdisplay_engine_s gvdisplay_engine_t;
-    typedef struct gvtext_engine_s gvtext_engine_t;
+    typedef struct gvtextlayout_engine_s gvtextlayout_engine_t;
 
     typedef struct htmllabel_t htmllabel_t;
 
index 8fe45fa02bfcb356cbdae45147ba298e800d184d..7a29c1429ab10d1a9dcd09ab4773c34f692fcb1d 100644 (file)
@@ -11,10 +11,10 @@ AM_CPPFLAGS = \
 LIBS = $(LIBLTDL) $(SOCKET_LIBS)
 
 pkginclude_HEADERS = gvc.h gvcint.h gvplugin.h \
-       gvplugin_render.h gvplugin_layout.h gvplugin_textlayout.h 
+       gvplugin_render.h gvplugin_layout.h gvplugin_textlayout.h gvplugin_device.h
 pkglib_LTLIBRARIES = libgvc.la
 
-libgvc_la_SOURCES = gvrender.c gvlayout.c gvtextlayout.c gvcontext.c \
-       gvjobs.c gvevent.c gvplugin.c gvconfig.c
+libgvc_la_SOURCES = gvrender.c gvlayout.c gvtextlayout.c gvdevice.c \
+       gvcontext.c gvjobs.c gvevent.c gvplugin.c gvconfig.c
 
 EXTRA_DIST = Makefile.old
index 4792e14047de3129e7577e2ed09bc0e3efa52fc0..c7767827905caead97c2da2d7192d592f6128c9d 100644 (file)
@@ -13,10 +13,10 @@ INCS =  -I. \
 
 DEFINES = -DHAVE_CONFIG_H -DGVLIBDIR=$(LIBDIR)
 
-HDRS = gvc.h gvcint.h gvplugin_render.h \
+HDRS = gvc.h gvcint.h gvplugin_render.h gvplugin_device.h \
        gvplugin_layout.h gvplugin_textlayout.h gvplugin.h
 
-OBJS = gvrender.o gvlayout.o gvcontext.o gvjobs.o \
+OBJS = gvrender.o gvlayout.o gvdevice.o gvcontext.o gvjobs.o \
        gvplugin.o gvconfig.o gvevent.o gvtextlayout.o
 
 libgvc.a : $(OBJS)
index 9f1b918dfa26b40152b769b3a72eac327c46f8cb..5022a9e08df68c7aaacc79a9fb8be64260ec2f18 100644 (file)
@@ -65,10 +65,14 @@ extern "C" {
                               char *fontname, double fontsize,
                               char *fontpath);
 
-/* render */
+/* device */
+
+    extern void gvdevice_initialize(GVC_t * gvc);
+    extern void gvdevice_finalize(GVC_t * gvc);
+    extern void gvdevice_begin_job(GVJ_t * job);
+    extern void gvdevice_end_job(GVJ_t * job);
 
-    extern void gvrender_initialize(GVC_t * gvc);
-    extern void gvrender_finalize(GVC_t * gvc);
+/* render */
 
     extern void gvrender_begin_job(GVJ_t * job);
     extern void gvrender_end_job(GVJ_t * job);
index 59d9b3f4840a5568968d18c043f754e90cc4970f..e2927a2ec19c3ca1e4a84044f9701fa927259e8d 100644 (file)
@@ -64,8 +64,13 @@ extern "C" {
        char **knowncolors;
        int sz_knowncolors;
        color_type_t color_type;
+       char *device;
     } gvrender_features_t;
 
+    typedef struct {
+       int flags;
+    } gvdevice_features_t;
+
     struct GVJ_s {
        GVJ_t *next;  /* linked list of jobs */
        GVJ_t *next_active;   /* linked list of active jobs (e.g. multiple windows) */
@@ -74,6 +79,10 @@ extern "C" {
        FILE *output_file;
        int output_lang;
 
+       gvdevice_engine_t *device_engine;       /* current device engine */
+       int device_id;          /* internal id of current device engine within plugin */
+       gvdevice_features_t *device_features;   /* features of current device */
+
        gvrender_engine_t *render_engine;       /* current render engine */
        int render_id;          /* internal id of current render engine within plugin */
        gvrender_features_t *render_features;   /* features of current render */
@@ -180,9 +189,8 @@ extern "C" {
 #undef ELEM
 
        void *display;          /* display-specific data for gvdisplay plugin */
-       gvdisplay_engine_t *display_engine; /* current display engine */
 
-       gvtext_engine_t *text_engine;   /* current text_layout engine */
+       gvtextlayout_engine_t *textlayout_engine;       /* current text_layout engine */
 
        /* gvrender_begin_job() */
        char *layout_type;      /* string name of layout type */
diff --git a/lib/gvc/gvdevice.c b/lib/gvc/gvdevice.c
new file mode 100644 (file)
index 0000000..1c56c59
--- /dev/null
@@ -0,0 +1,147 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+/*
+ *  graphics code generator wrapper
+ *
+ *  This library forms the socket for run-time loadable device plugins.  
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include "const.h"
+#include "types.h"
+#include "macros.h"
+
+#include "gvplugin_device.h"
+#include "gvc.h"
+
+int gvdevice_select(GVJ_t * job, char *str)
+{
+    GVC_t *gvc = job->gvc;
+    gv_plugin_t *plugin;
+    gvplugin_type_t *typeptr;
+#ifndef DISABLE_CODEGENS
+    codegen_info_t *cg_info;
+#endif
+
+    plugin = gvplugin_load(gvc, API_device, str);
+    if (plugin) {
+#ifndef DISABLE_CODEGENS
+       if (strcmp(plugin->packagename, "cg") == 0) {
+           cg_info = (codegen_info_t *) (plugin->typeptr);
+           job->codegen = cg_info->cg;
+           return cg_info->id;
+       } else {
+#endif
+           typeptr = plugin->typeptr;
+           job->device_engine = (gvdevice_engine_t *) (typeptr->engine);
+           job->device_features =
+               (gvdevice_features_t *) (typeptr->features);
+           job->device_id = typeptr->id;
+           return GVRENDER_PLUGIN;
+#ifndef DISABLE_CODEGENS
+       }
+#endif
+    }
+    return NO_SUPPORT;
+}
+
+int gvdevice_features(GVJ_t * job)
+{
+    gvdevice_engine_t *gvde = job->device_engine;
+    int features = 0;
+
+    if (gvde)
+       features = job->device_features->flags;
+    return features;
+}
+
+extern gvevent_key_binding_t gvevent_key_binding[];
+extern int gvevent_key_binding_size;
+
+void gvdevice_initialize(GVC_t * gvc)
+{
+    GVJ_t *job = gvc->job;
+    gvdevice_engine_t *gvde = job->device_engine;
+
+    if (gvde && gvde->initialize)
+           gvde->initialize(gvc, gvevent_key_binding, gvevent_key_binding_size);
+}
+
+void gvdevice_finalize(GVC_t * gvc)
+{
+    GVJ_t *job = gvc->active_jobs;
+    gvdevice_engine_t *gvde = job->device_engine;
+
+    if (gvde) {
+       if (gvde->finalize)
+           gvde->finalize(gvc);
+    }
+#ifndef DISABLE_CODEGENS
+    else {
+       codegen_t *cg = job->codegen;
+
+       if (cg && cg->reset)
+           cg->reset();
+    }
+#endif
+}
+
+void gvdevice_begin_job(GVJ_t * job)
+{
+    gvdevice_engine_t *gvde = job->device_engine;
+
+    if (gvde) {
+        if (gvde->begin_job)
+            gvde->begin_job(job);
+    }
+#if 0
+#ifndef DISABLE_CODEGENS
+    else {
+        codegen_t *cg = job->codegen;
+
+        if (cg && cg->begin_job)
+            cg->begin_job(job->output_file, job->g, job->gvc->lib, job->gvc->user,
+                          job->gvc->info, job->pagesArraySize);
+    }
+#endif
+#endif
+}
+
+void gvdevice_end_job(GVJ_t * job)
+{
+    gvdevice_engine_t *gvde = job->device_engine;
+
+    if (gvde && gvde->end_job)
+        gvde->end_job(job);
+#if 0
+#ifndef DISABLE_CODEGENS
+    else {
+        codegen_t *cg = job->codegen;
+
+        if (cg && cg->end_job)
+            cg->end_job();
+    }
+#endif
+#endif
+    job->gvc->lib = NULL;
+}
index da56e1e3aaf714e4e2a24fb9879cb70af72dfeb0..a1443c610dc3c6eeac706beec895e61a0b9ed576 100644 (file)
@@ -41,7 +41,7 @@ extern "C" {
  * The enumerated type is defined here.  The apis array is
  * inititialized in gvplugin.c by redefining ELEM and reinvoking APIS.
  */
-#define APIS ELEM(render) ELEM(layout) ELEM(textlayout)
+#define APIS ELEM(render) ELEM(layout) ELEM(textlayout) ELEM(device)
 
 #define ELEM(x) API_##x,
     typedef enum { APIS } api_t; /* API_render, API_layout, ... */
diff --git a/lib/gvc/gvplugin_device.h b/lib/gvc/gvplugin_device.h
new file mode 100644 (file)
index 0000000..ae2e141
--- /dev/null
@@ -0,0 +1,44 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#ifndef GVDEVICE_PLUGIN_H
+#define GVDEVICE_PLUGIN_H
+
+#include "gvplugin.h"
+#include "gvcint.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    struct gvdevice_engine_s {
+       void (*initialize) (GVC_t * gvc, gvevent_key_binding_t *keybindings, int numkeys);
+       void (*finalize) (GVC_t * gvc);
+       void (*begin_job) (GVJ_t * job);
+        void (*end_job) (GVJ_t * job);
+    };
+
+/* callbacks */
+    extern void gvevent_refresh(GVJ_t * job);
+    extern void gvevent_button_press(GVJ_t * job, int button, double x, double y);
+    extern void gvevent_button_release(GVJ_t * job, int button, double x, double y);
+    extern void gvevent_motion(GVJ_t * job, double x, double y);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* GVDEVICE_PLUGIN_H */
index 894eb9e434895c836323d7c0d1143118aafde92f..d86d9ecea78b7143748b774fc55c7da3c089cfbe 100644 (file)
@@ -25,8 +25,6 @@ extern "C" {
 #endif
 
     struct gvrender_engine_s {
-       void (*initialize) (GVC_t * gvc, gvevent_key_binding_t *keys, int numkeys);
-       void (*finalize) (GVC_t * gvc);
        void (*begin_job) (GVJ_t * job);
        void (*end_job) (GVJ_t * job);
        void (*begin_graph) (GVJ_t * job, char *graphname);
@@ -62,12 +60,6 @@ extern "C" {
                            int filled);
     };
 
-/* callbacks */
-    extern void gvevent_refresh(GVJ_t * job);
-    extern void gvevent_button_press(GVJ_t * job, int button, double x, double y);
-    extern void gvevent_button_release(GVJ_t * job, int button, double x, double y);
-    extern void gvevent_motion(GVJ_t * job, double x, double y);
-
 #ifdef __cplusplus
 }
 #endif
index 345f2b1219bb94e4111925058d6f23c6a3cdf43f..e7bdfa7b70f5dd42cea5d450ef1282934b134e45 100644 (file)
@@ -14,8 +14,8 @@
 *              AT&T Research, Florham Park NJ             *
 **********************************************************/
 
-#ifndef GVTEXT_PLUGIN_H
-#define GVTEXT_PLUGIN_H
+#ifndef GVTEXTLAYOUT_PLUGIN_H
+#define GVTEXTLAYOUT_PLUGIN_H
 
 #include "gvplugin.h"
 #include "gvcint.h"
 extern "C" {
 #endif
 
-    struct gvtext_engine_s {
+    struct gvtextlayout_engine_s {
        boolean (*width) (textline_t *textline, char *fontname, double fontsize, char* fontpath);
     };
 
 #ifdef __cplusplus
 }
 #endif
-#endif                         /* GVTEXT_PLUGIN_H */
+#endif                         /* GVTEXTLAYOUT_PLUGIN_H */
index 131fbe669de4b37f908a24f62b6d062fb1b9b906..11de867b5519ea40bd89412f587f2224c13f348d 100644 (file)
 /*
  *  graphics code generator wrapper
  *
- *  This library will eventually form the socket for run-time loadable
- *  render plugins.   Initially it just provides wrapper functions
- *  to the old codegens so that the changes can be locallized away from all
- *  the various codegen callers.
- *
+ *  This library forms the socket for run-time loadable render plugins.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -53,6 +49,7 @@ int gvrender_select(GVJ_t * job, char *str)
     GVC_t *gvc = job->gvc;
     gv_plugin_t *plugin;
     gvplugin_type_t *typeptr;
+    char *device;
 #ifndef DISABLE_CODEGENS
     codegen_info_t *cg_info;
 #endif
@@ -71,6 +68,17 @@ int gvrender_select(GVJ_t * job, char *str)
            job->render_features =
                (gvrender_features_t *) (typeptr->features);
            job->render_id = typeptr->id;
+           device = job->render_features->device;
+           if (device) {
+               plugin = gvplugin_load(gvc, API_device, device);
+               if (! plugin)
+                   return NO_SUPPORT;
+               typeptr = plugin->typeptr;
+               job->device_engine = (gvdevice_engine_t *) (typeptr->engine);
+               job->device_features =
+                   (gvdevice_features_t *) (typeptr->features);
+               job->device_id = typeptr->id;
+           }
            return GVRENDER_PLUGIN;
 #ifndef DISABLE_CODEGENS
        }
@@ -105,50 +113,6 @@ int gvrender_features(GVJ_t * job)
     return features;
 }
 
-extern gvevent_key_binding_t gvevent_key_binding[];
-extern int gvevent_key_binding_size;
-
-void gvrender_initialize(GVC_t * gvc)
-{
-    GVJ_t *job = gvc->job;
-    gvrender_engine_t *gvre = job->render_engine;
-
-    if (gvre) {
-       if (gvre->initialize)
-           gvre->initialize(gvc, gvevent_key_binding, gvevent_key_binding_size);
-    }
-#if 0 
-/* codegens don't have this entry point */
-#ifndef DISABLE_CODEGENS
-    else {
-       codegen_t *cg = job->codegen;
-
-       if (cg && cg->init)
-           cg->init();
-    }
-#endif
-#endif
-}
-
-void gvrender_finalize(GVC_t * gvc)
-{
-    GVJ_t *job = gvc->active_jobs;
-    gvrender_engine_t *gvre = job->render_engine;
-
-    if (gvre) {
-       if (gvre->finalize)
-           gvre->finalize(gvc);
-    }
-#ifndef DISABLE_CODEGENS
-    else {
-       codegen_t *cg = job->codegen;
-
-       if (cg && cg->reset)
-           cg->reset();
-    }
-#endif
-}
-
 void gvrender_begin_job(GVJ_t * job)
 {
     gvrender_engine_t *gvre = job->render_engine;
index 0b128fed8782e6467fe5164fbfd8ab6e2ccc59cf..9eadc10a06e62b6e06d42bd75480014e662c4c1d 100644 (file)
@@ -47,7 +47,7 @@ int gvtext_select(GVC_t * gvc, char *text_layout)
 
 double gvtext_width(GVC_t *gvc, textline_t *textline, char *fontname, double fontsize, char *fontpath)
 {
-    gvtext_engine_t *gvte = gvc->text_engine;
+    gvtextlayout_engine_t *gvte = gvc->textlayout_engine;
     boolean rc;
 
     if (gvte && gvte->width) {