]> granicus.if.org Git - graphviz/commitdiff
Merge display_plugin api into render_plugin's
authorellson <devnull@localhost>
Thu, 3 Feb 2005 05:23:43 +0000 (05:23 +0000)
committerellson <devnull@localhost>
Thu, 3 Feb 2005 05:23:43 +0000 (05:23 +0000)
Add initialize to render api - set up display for one or more windows
Add finalize to render api - event loop for one or more windows
Modify emit_jobs to invoke initialize and finalize on language changes

lib/common/emit.c
lib/gvc/Makefile.am
lib/gvc/Makefile.old
lib/gvc/gvc.h
lib/gvc/gvdisplay.c [deleted file]
lib/gvc/gvplugin_display.h [deleted file]
lib/gvc/gvplugin_render.h
lib/gvc/gvrender.c

index bfd42e7948ed82ef91a7cb1546ad1b2d20a0afe3..584b93bdd9c571a1bce461145f0cc5baf45a8261 100644 (file)
@@ -344,9 +344,6 @@ static void emit_reset(GVC_t * gvc, graph_t * g)
     for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
        ND_state(n) = 0;
     }
-
-    /* reset renderer */
-    gvrender_reset(gvc);
 }
 
 static void emit_background(GVC_t * gvc, graph_t *g, boxf pageBox)
@@ -1007,9 +1004,6 @@ static void emit_init_job(GVC_t * gvc, graph_t * g)
 
     init_layering(gvc, g);
 
-    gvc->job->gvc = gvc;
-    gvc->job->g = g;
-
     init_job_flags(gvc->job, g);
 
     init_job_margin(gvc);
@@ -1557,6 +1551,7 @@ static FILE *file_select(char *str)
 void emit_jobs (GVC_t * gvc, graph_t * g)
 {
     gvrender_job_t *job;
+    char *prev_langname = NULL;
 
     for (job = gvrender_first_job(gvc); job; job = gvrender_next_job(gvc)) {
         if (!job->output_file) {        /* if not yet opened */
@@ -1565,9 +1560,20 @@ void emit_jobs (GVC_t * gvc, graph_t * g)
             } else {
                 job->output_file = file_select(job->output_filename);
             }
+        }
+       if (job->output_langname != prev_langname) {
+           prev_langname = job->output_langname;
             job->output_lang = gvrender_select(gvc, job->output_langname);
             assert(job->output_lang != NO_SUPPORT); /* should have been verified already */
-        }
+           gvrender_initialize(gvc);
+       }
+
+       job->gvc = gvc;
+       job->g = g;
+
         emit_job(gvc, g);
+
+       if (!job->next || job->next->output_langname != prev_langname)
+           gvrender_finalize(gvc);
     }
 }
index d17981a361c5b5bbb872b1c9206856944bf24f26..db9c23908d052718dadcdfebf049bdbcd7501f1d 100644 (file)
@@ -15,10 +15,10 @@ AM_CPPFLAGS = \
 
 pkginclude_HEADERS = gvc.h gvcint.h gvplugin.h \
        gvplugin_render.h gvplugin_layout.h \
-       gvplugin_text.h gvplugin_display.h
+       gvplugin_text.h 
 pkglib_LTLIBRARIES = libgvc.la
 
-libgvc_la_SOURCES = gvrender.c gvlayout.c gvdisplay.c gvtext.c gvcontext.c \
+libgvc_la_SOURCES = gvrender.c gvlayout.c gvtext.c gvcontext.c \
        gvjobs.c gvevent.c gvemit.c gvplugin.c gvconfig.c
 
 EXTRA_DIST = Makefile.old
index 0f44db71f91520d7a02d5c5d7ad45bb1c58c9294..d39f174d9b9479d933fc703aaa14d30570d7847d 100644 (file)
@@ -17,7 +17,7 @@ HDRS = gvc.h gvcint.h gvplugin_render.h \
        gvplugin_layout.h gvplugin.h
 
 OBJS = gvrender.o gvlayout.o gvcontext.o gvjobs.o \
-       gvemit.o gvplugin.o gvconfig.o gvdisplay.o  gvevent.o gvtext.o
+       gvemit.o gvplugin.o gvconfig.o gvevent.o gvtext.o
 
 libgvc.a : $(OBJS)
        $(RM) libgvc.a
index 86bfa67b315b203be6b7ec90f1168455d7c7ae8c..1654bd2f6c46110d669ca93048a7ca0c78a1da57 100644 (file)
@@ -63,18 +63,12 @@ extern "C" {
                               char *fontname, double fontsize,
                               char *fontpath);
 
-/* display */
-
-    extern int gvdisplay_select(GVC_t * gvc, char *display);
-    extern void gvdisplay_init(GVC_t *gvc);
-    extern void gvdisplay_process(GVC_t *gvc);
-    extern void gvdisplay_deinit(GVC_t *gvc);
-
 /* render */
 
     extern int gvrender_select(GVC_t * gvc, char *lang);
     extern int gvrender_features(GVC_t * gvc);
-    extern void gvrender_reset(GVC_t * gvc);
+    extern void gvrender_initialize(GVC_t * gvc);
+    extern void gvrender_finalize(GVC_t * gvc);
     extern void gvrender_begin_job(GVC_t * gvc);
     extern void gvrender_end_job(GVC_t * gvc);
     extern void gvrender_begin_graph(GVC_t * gvc, graph_t * g);
diff --git a/lib/gvc/gvdisplay.c b/lib/gvc/gvdisplay.c
deleted file mode 100644 (file)
index 84227c8..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* $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             *
-**********************************************************/
-
-/*
- *  display engine wrapper
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-
-#include "const.h"
-#include "types.h"
-#include "macros.h"
-
-#include "gvplugin_display.h"
-#include "gvc.h"
-
-int gvdisplay_select(GVC_t * gvc, char *display)
-{
-    gv_plugin_t *plugin;
-    gvplugin_type_t *typeptr;
-
-    plugin = gvplugin_load(gvc, API_display, display);
-    if (plugin) {
-       typeptr = plugin->typeptr;
-       gvc->display_engine = (gvdisplay_engine_t *) (typeptr->engine);
-       return GVRENDER_PLUGIN; /* FIXME - need more suitable success code */
-    }
-    return NO_SUPPORT;
-}
-
-void gvdisplay_init(GVC_t *gvc)
-{
-    gvdisplay_engine_t *gvde = gvc->display_engine;
-
-    if (gvde && gvde->init) {
-       gvde->init(gvc);
-    }
-}
-
-void gvdisplay_process(GVC_t *gvc)
-{
-    gvdisplay_engine_t *gvde = gvc->display_engine;
-
-    if (gvde && gvde->process) {
-       gvde->process(gvc);
-    }
-}
-
-void gvdisplay_deinit(GVC_t *gvc)
-{
-    gvdisplay_engine_t *gvde = gvc->display_engine;
-
-    if (gvde && gvde->deinit) {
-       gvde->deinit(gvc);
-    }
-}
diff --git a/lib/gvc/gvplugin_display.h b/lib/gvc/gvplugin_display.h
deleted file mode 100644 (file)
index 130b2ad..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* $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 GVDISPLAY_PLUGIN_H
-#define GVDISPLAY_PLUGIN_H
-
-#include "gvplugin.h"
-#include "gvcint.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-    struct gvdisplay_engine_s {
-       void (*init) (GVC_t * gvc);
-       void (*process) (GVC_t * gvc);
-       void (*deinit) (GVC_t * gvc);
-    };
-
-/* event callbacks in gvevent.c */
-
-    extern void gvevent_refresh(gvrender_job_t * job);
-#if 0
-    extern void gvevent_button_press(gvrender_job_t * job, int button, double x, double y);
-    extern void gvevent_motion(gvrender_job_t * job, double x, double y);
-    extern void gvevent_button_release(gvrender_job_t *job, int button, double x,
-double y);
-    extern int gvevent_key_press(gvrender_job_t * job, int key);
-    extern void gvevent_reconfigure_normal(gvrender_job_t * job, unsigned int width, unsigned int height);
-    extern void gvevent_reconfigure_fit_mode(gvrender_job_t * job, unsigned int width, unsigned int height);
-
-    extern void gvevent_configure(gvrender_job_t * job, XConfigureEvent * cev);
-    extern void gvevent_expose(gvrender_job_t * job, XExposeEvent * eev);
-    extern void gvevent_client_message(gvrender_job_t * job, XClientMessageEvent * cmev);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /* GVDISPLAY_PLUGIN_H */
index 490e51ea121e23171297278124eb3bf24618cc4d..3540869823ec814e4284e8676f9f647e32be700b 100644 (file)
@@ -25,6 +25,8 @@ extern "C" {
 #endif
 
     struct gvrender_engine_s {
+       void (*initialize) (GVC_t * gvc);
+       void (*finalize) (GVC_t * gvc);
        void (*begin_job) (gvrender_job_t * job);
        void (*end_job) (gvrender_job_t * job);
        void (*begin_graph) (gvrender_job_t * job, char *graphname);
index bcec1162275dfef51f782c5bd05007861c59b9b0..b79536de4d9cc6f15d6f6409ddf1a43105152c7d 100644 (file)
@@ -106,13 +106,39 @@ int gvrender_features(GVC_t * gvc)
     return features;
 }
 
-void gvrender_reset(GVC_t * gvc)
+void gvrender_initialize(GVC_t * gvc)
 {
+    gvrender_job_t *job = gvc->job;
+    gvrender_engine_t *gvre = job->render_engine;
+
+    if (gvre) {
+       if (gvre->initialize)
+           gvre->initialize(gvc);
+    }
+#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)
+{
     gvrender_job_t *job = gvc->job;
     gvrender_engine_t *gvre = job->render_engine;
 
-    if (!gvre) {
+    if (gvre) {
+       if (gvre->finalize)
+           gvre->finalize(gvc);
+    }
+#ifndef DISABLE_CODEGENS
+    else {
        codegen_t *cg = job->codegen;
 
        if (cg && cg->reset)