if (job->output_file) {
if (gvc->viewNum > 0) {
gvrender_end_job(job);
+ gvdevice_end_job(job);
emit_once_reset();
gvc->viewNum = 0;
}
init_job_viewport(job, g);
init_job_pagination(job, g);
+ gvdevice_begin_job(job);
gvrender_begin_job(job);
switch (job->output_lang) {
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;
void dotneato_terminate(GVC_t * gvc)
{
if (gvc->active_jobs)
- gvrender_finalize(gvc);
+ gvdevice_finalize(gvc);
emit_jobs_eof(gvc);
exit(graphviz_errors + agerrors());
}
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;
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
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)
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);
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) */
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 */
#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 */
--- /dev/null
+/* $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;
+}
* 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, ... */
--- /dev/null
+/* $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 */
#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);
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
* 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 */
/*
* 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
GVC_t *gvc = job->gvc;
gv_plugin_t *plugin;
gvplugin_type_t *typeptr;
+ char *device;
#ifndef DISABLE_CODEGENS
codegen_info_t *cg_info;
#endif
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
}
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;
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) {