From 49f1083ed4a8f50d52b33961a771982dc06f56cc Mon Sep 17 00:00:00 2001 From: ellson Date: Sun, 25 Jun 2006 04:35:23 +0000 Subject: [PATCH] eliminate libgd from core --- lib/common/Makefile.am | 10 ++--- lib/common/diagen.c | 85 +++++++++++++++++++++++++++++++++++++----- lib/common/shapes.c | 7 ---- lib/gvc/Makefile.am | 11 +----- lib/gvc/gvconfig.c | 38 +------------------ lib/gvc/gvrender.c | 7 ---- 6 files changed, 81 insertions(+), 77 deletions(-) diff --git a/lib/common/Makefile.am b/lib/common/Makefile.am index b8907e2cd..e2928810e 100644 --- a/lib/common/Makefile.am +++ b/lib/common/Makefile.am @@ -16,13 +16,9 @@ noinst_HEADERS = render.h utils.h memory.h \ const.h macros.h htmllex.h htmltable.h pointset.h noinst_LTLIBRARIES = libcommon_C.la -if WITH_LIBGD -GD_CODEGENS = gdgen.c vrmlgen.c -endif - if WITH_CODEGENS CODEGENS = $(GD_CODEGENS) diagen.c figgen.c hpglgen.c mapgen.c mifgen.c mpgen.c \ - picgen.c psgen.c svggen.c vtxgen.c ps.txt xdgen.c color_names + picgen.c vtxgen.c xdgen.c endif @@ -30,9 +26,9 @@ libcommon_C_la_SOURCES = arrows.c colxlate.c fontmetrics.c \ args.c memory.c globals.c htmllex.c htmlparse.y htmltable.c input.c \ pointset.c postproc.c routespl.c splines.c psusershape.c \ timing.c labels.c ns.c shapes.c utils.c geom.c \ - output.c emit.c $(CODEGENS) + output.c emit.c ps.txt color_names $(CODEGENS) -psgen.o psgen.lo : ps.h +utils.o utils.lo : ps.h ps.h : ps.txt $(AWK) -f $(top_srcdir)/awk/stringize.awk ps.txt > ps.h diff --git a/lib/common/diagen.c b/lib/common/diagen.c index c51e223e6..3a3d7fae7 100644 --- a/lib/common/diagen.c +++ b/lib/common/diagen.c @@ -132,6 +132,81 @@ static int dia_printf(const char *format, ...) #endif } +#define SVG_COLORS_P 0 + +static int dia_comparestr(const void *s1, const void *s2) +{ + return strcmp(*(char **) s1, *(char **) s2); +} + +static char *dia_resolve_color(char *name) +{ +/* color names from http://www.w3.org/TR/SVG/types.html */ +/* NB. List must be LANG_C sorted */ + static char *svg_known_colors[] = { + "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", + "beige", "bisque", "black", "blanchedalmond", "blue", + "blueviolet", "brown", "burlywood", + "cadetblue", "chartreuse", "chocolate", "coral", + "cornflowerblue", "cornsilk", "crimson", "cyan", + "darkblue", "darkcyan", "darkgoldenrod", "darkgray", + "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", + "darkolivegreen", "darkorange", "darkorchid", "darkred", + "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", + "darkslategrey", "darkturquoise", "darkviolet", "deeppink", + "deepskyblue", "dimgray", "dimgrey", "dodgerblue", + "firebrick", "floralwhite", "forestgreen", "fuchsia", + "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", + "green", "greenyellow", "grey", + "honeydew", "hotpink", "indianred", + "indigo", "ivory", "khaki", + "lavender", "lavenderblush", "lawngreen", "lemonchiffon", + "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", + "lightgray", "lightgreen", "lightgrey", "lightpink", + "lightsalmon", "lightseagreen", "lightskyblue", + "lightslategray", "lightslategrey", "lightsteelblue", + "lightyellow", "lime", "limegreen", "linen", + "magenta", "maroon", "mediumaquamarine", "mediumblue", + "mediumorchid", "mediumpurple", "mediumseagreen", + "mediumslateblue", "mediumspringgreen", "mediumturquoise", + "mediumvioletred", "midnightblue", "mintcream", + "mistyrose", "moccasin", + "navajowhite", "navy", "oldlace", + "olive", "olivedrab", "orange", "orangered", "orchid", + "palegoldenrod", "palegreen", "paleturquoise", + "palevioletred", "papayawhip", "peachpuff", "peru", "pink", + "plum", "powderblue", "purple", + "red", "rosybrown", "royalblue", + "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", + "sienna", "silver", "skyblue", "slateblue", "slategray", + "slategrey", "snow", "springgreen", "steelblue", + "tan", "teal", "thistle", "tomato", "turquoise", + "violet", + "wheat", "white", "whitesmoke", + "yellow", "yellowgreen", + }; + + static char buf[SMALLBUF]; + char *tok; + gvcolor_t color; + + tok = canontoken(name); + if (!SVG_COLORS_P || (bsearch(&tok, svg_known_colors, + sizeof(svg_known_colors) / sizeof(char *), + sizeof(char *), dia_comparestr) == NULL)) { + /* if tok was not found in known_colors */ + if (streq(tok, "transparent")) { + tok = "none"; + } else { + colorxlate(name, &color, RGBA_BYTE); + sprintf(buf, "#%02x%02x%02x", + color.u.rgba[0], color.u.rgba[1], color.u.rgba[2]); + tok = buf; + } + } + return tok; +} + static void dia_reset(void) { @@ -166,16 +241,6 @@ static pointf diapt(point p) return rv; } -static char *dia_resolve_color(char *name) -{ - extern char *svg_resolve_color(char *, int); -#ifdef DIA_KNOWS_SVG_COLORNAMES - return svg_resolve_color(name, 1); -#else - return svg_resolve_color(name, 0); -#endif -} - static void dia_grstyle(context_t * cp) { if (cp->pencolor != DEFAULT_COLOR) { diff --git a/lib/common/shapes.c b/lib/common/shapes.c index c32dbabb8..465d60ed5 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -1210,13 +1210,6 @@ static void poly_gencode(GVJ_t * job, node_t * n) xsize = (double)(ND_lw_i(n) + ND_rw_i(n)) / POINTS(ND_width(n)); ysize = (double)ND_ht_i(n) / POINTS(ND_height(n)); -#if defined(WITH_CODEGENS) && defined(HAVE_GD_PNG) - /* this is bad, but it's because of how the VRML driver works */ - if ((job->codegen == &VRML_CodeGen) && (peripheries == 0)) { - peripheries = 1; - } -#endif - if (ND_shape(n) == point_desc) { checkStyle(n, &style); if (style & INVISIBLE) diff --git a/lib/gvc/Makefile.am b/lib/gvc/Makefile.am index 1f163cfdd..fac53f5d0 100644 --- a/lib/gvc/Makefile.am +++ b/lib/gvc/Makefile.am @@ -31,20 +31,11 @@ libgvc_C_la_LIBADD = $(top_builddir)/lib/common/libcommon_C.la # so it is linked with an empty table of builtins. libgvc_la_LDFLAGS = -version-info @VERSION_INFO@ libgvc_la_SOURCES = $(libgvc_C_la_SOURCES) no_builtins.c demand_loading.c -if WITH_MYLIBGD libgvc_la_LIBADD = $(libgvc_C_la_LIBADD) \ - $(top_builddir)/lib/gd/libgvgd_C.la \ $(top_builddir)/lib/cdt/libcdt.la \ $(top_builddir)/lib/graph/libgraph.la \ $(top_builddir)/lib/pathplan/libpathplan.la \ - @ICONV_LIBS@ @FC_LIBS@ @FT_LIBS@ @JPEG_LIBS@ @PNG_LIBS@ @EXPAT_LIBS@ @Z_LIBS@ -else -libgvc_la_LIBADD = $(libgvc_C_la_LIBADD) \ - $(top_builddir)/lib/cdt/libcdt.la \ - $(top_builddir)/lib/graph/libgraph.la \ - $(top_builddir)/lib/pathplan/libpathplan.la \ - @GD_LIBS@ -endif + @EXPAT_LIBS@ @Z_LIBS@ #For use without plugins. # so it needs to be linked with a preset table of builtins, e.g. dot_builtins.c, diff --git a/lib/gvc/gvconfig.c b/lib/gvc/gvconfig.c index 6eb82f4d1..2fdef0c93 100644 --- a/lib/gvc/gvconfig.c +++ b/lib/gvc/gvconfig.c @@ -46,12 +46,9 @@ extern const bool Demand_Loading; extern codegen_t QPDF_CodeGen, QEPDF_CodeGen, QBM_CodeGen; #endif - extern codegen_t FIG_CodeGen, HPGL_CodeGen, MAP_CodeGen, + extern codegen_t FIG_CodeGen, HPGL_CodeGen, MIF_CodeGen, XDot_CodeGen, MP_CodeGen, PIC_CodeGen, - PS_CodeGen, DIA_CodeGen, SVG_CodeGen, VTX_CodeGen; -#ifdef HAVE_LIBGD - extern codegen_t GD_CodeGen, memGD_CodeGen, VRML_CodeGen; -#endif + DIA_CodeGen, VTX_CodeGen; #endif /* @@ -363,51 +360,20 @@ static void config_rescan(GVC_t *gvc, char *config_path) #define MAX_CODEGENS 100 static codegen_info_t cg[MAX_CODEGENS] = { - {&PS_CodeGen, "ps", POSTSCRIPT}, - {&PS_CodeGen, "ps2", PDF}, {&HPGL_CodeGen, "hpgl", HPGL}, {&HPGL_CodeGen, "pcl", PCL}, {&MIF_CodeGen, "mif", MIF}, {&PIC_CodeGen, "pic", PIC_format}, -#ifdef HAVE_LIBGD - {&GD_CodeGen, "gd", GD}, -#ifdef HAVE_LIBZ - {&GD_CodeGen, "gd2", GD2}, -#endif -#ifdef HAVE_GD_GIF - {&GD_CodeGen, "gif", GIF}, -#endif -#ifdef HAVE_GD_JPEG - {&GD_CodeGen, "jpg", JPEG}, - {&GD_CodeGen, "jpeg", JPEG}, -#endif -#ifdef HAVE_GD_PNG - {&GD_CodeGen, "png", PNG}, - {&VRML_CodeGen, "vrml", VRML}, -#endif - {&GD_CodeGen, "wbmp", WBMP}, -#ifdef HAVE_GD_XPM - {&GD_CodeGen, "xbm", XBM}, - {&GD_CodeGen, "xpm", XBM}, -#endif -#endif - #ifdef QUARTZ_RENDER {&QPDF_CodeGen, "pdf", QPDF}, {&QEPDF_CodeGen, "epdf", QEPDF}, #endif /* QUARTZ_RENDER */ - {&MAP_CodeGen, "ismap", ISMAP}, - {&MAP_CodeGen, "imap", IMAP}, - {&MAP_CodeGen, "cmap", CMAP}, - {&MAP_CodeGen, "cmapx", CMAPX}, {&VTX_CodeGen, "vtx", VTX}, {&MP_CodeGen, "mp", METAPOST}, {&FIG_CodeGen, "fig", FIG}, - {&SVG_CodeGen, "svg", SVG}, #ifdef HAVE_LIBZ - {&SVG_CodeGen, "svgz", SVGZ}, {&DIA_CodeGen, "dia", DIA}, #endif #define DUMMY_CodeGen XDot_CodeGen diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index 3eb468838..f47580187 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -44,10 +44,6 @@ extern int emit_once(char *str); -#ifdef WITH_CODEGENS -extern codegen_t PS_CodeGen; -#endif - /* storage for temporary hacks until client API is FP */ static pointf *AF; static int sizeAF; @@ -119,9 +115,6 @@ int gvrender_features(GVJ_t * job) features |= GVRENDER_DOES_ARROWS; if (cg->begin_layer) features |= GVRENDER_DOES_LAYERS; - /* WARNING - nasty hack to avoid modifying old codegens */ - if (cg == &PS_CodeGen) - features |= GVRENDER_DOES_MULTIGRAPH_OUTPUT_FILES; } } #endif -- 2.40.0