remove all xrender and all xcb code, remove detection as well. Fix a couple of potentially uninitialized variables

This commit is contained in:
Stefan Frederik 2022-01-19 00:49:46 +01:00
parent 6941451d9b
commit 1fb23208bc
9 changed files with 31 additions and 208 deletions

View File

@ -23,12 +23,6 @@ print [@/*************************************************************/
print {\n\n/* Define this var if cairo is available and is to be used */\n}
print_ternary ?libs/gui/cairo/presents {#define HAS_CAIRO 1} {/*#undef HAS_CAIRO */}
print {\n\n/* Define this var if Xlib's xcb is available */\n}
print_ternary ?libs/gui/xcb/presents {#define HAS_XCB 1} {/*#undef HAS_XCB */}
print {\n\n/* Define this var if Xlib's xrender is available */\n}
print_ternary ?libs/gui/xrender/presents {#define HAS_XRENDER 1} {/*#undef HAS_RENDER */}
print {\n\n/* Define this var if dup2(2) is available */\n}
print_ternary ?libs/io/dup2/presents {#define HAS_DUP2 1} {/*#undef HAS_DUP2 */}

View File

@ -164,22 +164,6 @@ int hook_detect_host()
return 0;
}
static void disable_xcb(void)
{
put("libs/gui/xcb/presents", "");
put("libs/gui/xcb/includes", "");
put("libs/gui/xcb/cflags", "");
put("libs/gui/xcb/ldflags", "");
put("libs/gui/xcb_render/presents", "");
put("libs/gui/xcb_render/includes", "");
put("libs/gui/xcb_render/cflags", "");
put("libs/gui/xcb_render/ldflags", "");
put("libs/gui/xgetxcbconnection/presents", "");
put("libs/gui/xgetxcbconnection/includes", "");
put("libs/gui/xgetxcbconnection/cflags", "");
put("libs/gui/xgetxcbconnection/ldflags", "");
}
/* Runs when things should be detected for the host->target system (commands
that will be executed on host but will produce files to be used on target) */
int hook_detect_target()
@ -246,26 +230,6 @@ int hook_detect_target()
require("fstools/awk", 0, 1);
require("libs/gui/xpm/*", 0, 1);
require("libs/gui/cairo/*", 0, 0);
require("libs/gui/xrender/*", 0, 0);
if (require("libs/gui/cairo-xcb/*", 0, 0) != 0) {
put("libs/gui/xcb/presents", sfalse);
}
else if (require("libs/gui/xcb/*", 0, 0) == 0) {
/* if xcb is used, the code requires these: */
require("libs/gui/xgetxcbconnection/*", 0, 0);
if (!istrue(get("libs/gui/xgetxcbconnection/presents"))) {
report("Disabling xcb because xgetxcbconnection is not found...\n");
disable_xcb();
}
else {
require("libs/gui/xcb_render/*", 0, 0);
if (!istrue(get("libs/gui/xcb_render/presents"))) {
report("Disabling xcb because xcb_render is not found...\n");
disable_xcb();
}
}
}
return 0;
}
@ -315,8 +279,6 @@ int hook_generate()
printf(" tcl: %s\n", get("/target/libs/script/tcl/ldflags"));
printf(" tk: %s\n", get("/target/libs/script/tk/ldflags"));
printf(" cairo: %s\n", istrue(get("/target/libs/gui/cairo/presents")) ? "yes" : "no");
printf(" xrender: %s\n", istrue(get("/target/libs/gui/xrender/presents")) ? "yes" : "no");
printf(" xcb: %s\n", istrue(get("/target/libs/gui/xcb/presents")) ? "yes" : "no");
printf("\nConfiguration complete, ready to compile.\n\n");
}

View File

@ -2380,7 +2380,7 @@ void draw_graph(int i, const int flags, Graph_ctx *gr)
int p, dset, ofs;
int poly_npoints;
int first, last;
double xx;
double xx; /* the p-th sweep variable value: xctx->graph_values[sweep_idx][p] */
double start;
double end;
int n_bits = 1, wrap;
@ -2475,7 +2475,7 @@ void draw_graph(int i, const int flags, Graph_ctx *gr)
sweepvar_wrap++;
} /* for(dset...) */
bbox(END, 0.0, 0.0, 0.0, 0.0);
show_node_measures(measure_p, measure_x, measure_prev_x, bus_msb, wave_color,
if(measure_p != -1) show_node_measures(measure_p, measure_x, measure_prev_x, bus_msb, wave_color,
idx, idx_arr, n_bits, n_nodes, ntok, wcnt, gr);
my_free(1403, &point);

View File

@ -126,16 +126,6 @@ Pixmap cad_icon_pixmap=0, cad_icon_mask=0;
/* char *cad_icon[] */
Pixmap *pixmap = NULL;
Visual *visual;
#if HAS_XRENDER==1
XRenderPictFormat *render_format;
#endif
#if HAS_XCB==1
xcb_connection_t *xcbconn;
xcb_render_pictforminfo_t format_rgb, format_rgba;
xcb_screen_t *screen_xcb;
xcb_visualtype_t *visual_xcb;
#endif /*HAS_XCB */
/* ---------------------------------------------- */
/* These variables are mirrored in tcl code */

View File

@ -278,36 +278,34 @@ void merge_inst(int k,FILE *fd)
int i;
char *prop_ptr=NULL;
char *tmp = NULL;
xInstance *ptr;
i=xctx->instances;
check_inst_storage();
ptr=xctx->inst;
ptr[i].name=NULL;
xctx->inst[i].name=NULL;
load_ascii_string(&tmp, fd);
/* avoid as much as possible calls to rel_sym_path (slow) */
#ifdef __unix__
if(tmp[0] == '/') my_strdup(763, &ptr[i].name, rel_sym_path(tmp));
else my_strdup(755, &ptr[i].name,tmp);
if(tmp[0] == '/') my_strdup(763, &xctx->inst[i].name, rel_sym_path(tmp));
else my_strdup(755, &xctx->inst[i].name,tmp);
#else
my_strdup(780, &ptr[i].name, rel_sym_path(tmp));
my_strdup(780, &xctx->inst[i].name, rel_sym_path(tmp));
#endif
my_free(756, &tmp);
if(fscanf(fd, "%lf %lf %hd %hd",&ptr[i].x0, &ptr[i].y0,&ptr[i].rot, &ptr[i].flip) < 4) {
if(fscanf(fd, "%lf %lf %hd %hd",&xctx->inst[i].x0, &xctx->inst[i].y0,&xctx->inst[i].rot, &xctx->inst[i].flip) < 4) {
fprintf(errfp,"WARNING: missing fields for INSTANCE object, ignoring.\n");
read_line(fd, 0);
return;
}
ptr[i].sel=0;
ptr[i].flags=0;
ptr[i].color=-10000;
ptr[i].ptr=-1;
ptr[i].prop_ptr=NULL;
ptr[i].instname=NULL;
ptr[i].lab=NULL; /* assigned in link_symbols_to_instances */
ptr[i].node=NULL;
xctx->inst[i].sel=0;
xctx->inst[i].flags=0;
xctx->inst[i].color=-10000;
xctx->inst[i].ptr=-1;
xctx->inst[i].prop_ptr=NULL;
xctx->inst[i].instname=NULL;
xctx->inst[i].lab=NULL; /* assigned in link_symbols_to_instances */
xctx->inst[i].node=NULL;
load_ascii_string(&prop_ptr,fd);
if(!k) hash_all_names(i);
new_prop_string(i, prop_ptr, k, tclgetboolvar("disable_unique_names"));
new_prop_string(i, prop_ptr, k, tclgetboolvar("disable_unique_names")); /* will also assign .instname */
/* the final tmp argument is zero for the 1st call and used in */
/* new_prop_string() for cleaning some internal caches. */
if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"highlight",0), "true"))
@ -437,7 +435,7 @@ void merge_file(int selection_load, const char ext[])
xctx->mousey_snap = 0.;
}
my_free(875, &aux_ptr);
link_symbols_to_instances(old);
link_symbols_to_instances(old); /* in case of paste/merge will set instances .sel to SELECTED */
fclose(fd);
xctx->ui_state |= STARTMERGE;
dbg(1, "merge_file(): loaded file:wire=%d inst=%d ui_state=%ld\n",

View File

@ -555,6 +555,7 @@ static void load_inst(int k, FILE *fd)
#else
my_strdup2(777, &xctx->inst[i].name, rel_sym_path(name));
#endif
my_free(884, &tmp);
if(fscanf(fd, "%lf %lf %hd %hd", &xctx->inst[i].x0, &xctx->inst[i].y0,
&xctx->inst[i].rot, &xctx->inst[i].flip) < 4) {
fprintf(errfp,"WARNING: missing fields for INSTANCE object, ignoring.\n");
@ -578,7 +579,6 @@ static void load_inst(int k, FILE *fd)
xctx->inst[i].prop_ptr? xctx->inst[i].prop_ptr:"<NULL>");
xctx->instances++;
}
my_free(884, &tmp);
my_free(885, &prop_ptr);
}

View File

@ -1146,15 +1146,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
#ifdef HAS_POPEN
my_snprintf(res, S(res), "HAS_POPEN=%d\n", HAS_POPEN); Tcl_AppendResult(interp, res, NULL);
#endif
#ifdef HAS_XRENDER
my_snprintf(res, S(res), "HAS_XRENDER=%d\n", HAS_XRENDER); Tcl_AppendResult(interp, res, NULL);
#endif
#ifdef HAS_CAIRO
my_snprintf(res, S(res), "HAS_CAIRO=%d\n", HAS_CAIRO); Tcl_AppendResult(interp, res, NULL);
#endif
#ifdef HAS_XCB
my_snprintf(res, S(res), "HAS_XCB=%d\n", HAS_XCB); Tcl_AppendResult(interp, res, NULL);
#endif
#ifdef XSCHEM_SHAREDIR
my_snprintf(res, S(res), "XSCHEM_SHAREDIR=%s\n", XSCHEM_SHAREDIR); Tcl_AppendResult(interp, res, NULL);
#endif
@ -1712,7 +1706,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"new_schematic"))
{
int r;
int r = -1;
char s[20];
cmd_found = 1;
if(argc == 3) r = new_schematic(argv[2], NULL, NULL);

View File

@ -871,28 +871,6 @@ void tclexit(ClientData s)
if(init_done) xwin_exit();
}
#if HAS_XCB==1
/* from xcb.freedesktop.org -- don't ask me what it does... 20171125 */
static xcb_visualtype_t *find_visual(xcb_connection_t *xcbconn, xcb_visualid_t visual)
{
xcb_screen_iterator_t screen_iter = xcb_setup_roots_iterator(xcb_get_setup(xcbconn));
for (; screen_iter.rem; xcb_screen_next(&screen_iter)) {
xcb_depth_iterator_t depth_iter = xcb_screen_allowed_depths_iterator(screen_iter.data);
for (; depth_iter.rem; xcb_depth_next(&depth_iter)) {
xcb_visualtype_iterator_t visual_iter = xcb_depth_visuals_iterator(depth_iter.data);
for (; visual_iter.rem; xcb_visualtype_next(&visual_iter)) {
if (visual == visual_iter.data->visual_id) {
return visual_iter.data;
}
}
}
}
return NULL;
}
#endif /*HAS_XCB */
int source_tcl_file(char *s)
{
char tmp[1024];
@ -1497,6 +1475,10 @@ void change_linewidth(double w)
void resetcairo(int create, int clear, int force_or_resize)
{
#if HAS_CAIRO==1
cairo_font_options_t *options;
options = cairo_font_options_create();
cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_FAST);
cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_SLIGHT);
dbg(1, "resetcairo() %d, %d, %d\n", create, clear, force_or_resize);
if(clear && force_or_resize) {
/* xctx->cairo_save_sfc is based on pixmap and pixmaps are not resizeable, so on resize
@ -1509,43 +1491,25 @@ void resetcairo(int create, int clear, int force_or_resize)
}
if(create && force_or_resize) {
/***** Create Cairo save buffer drawing area *****/
#if HAS_XRENDER==1
#if HAS_XCB==1
xctx->cairo_save_sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn, screen_xcb, xctx->save_pixmap,
&format_rgb, xctx->xrect[0].width, xctx->xrect[0].height);
#else
xctx->cairo_save_sfc = cairo_xlib_surface_create_with_xrender_format(display, xctx->save_pixmap,
DefaultScreenOfDisplay(display), render_format, xctx->xrect[0].width, xctx->xrect[0].height);
#endif /* HAS_XCB */
#else
xctx->cairo_save_sfc =
cairo_xlib_surface_create(display, xctx->save_pixmap, visual, xctx->xrect[0].width, xctx->xrect[0].height);
#endif /* HAS_XRENDER */
if(cairo_surface_status(xctx->cairo_save_sfc)!=CAIRO_STATUS_SUCCESS) {
fprintf(errfp, "ERROR: invalid cairo xcb surface\n");
}
xctx->cairo_save_ctx = cairo_create(xctx->cairo_save_sfc);
cairo_select_font_face(xctx->cairo_save_ctx, tclgetvar("cairo_font_name"),
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(xctx->cairo_save_ctx, 20);
cairo_set_font_options(xctx->cairo_save_ctx, options);
cairo_set_line_width(xctx->cairo_save_ctx, 1);
cairo_set_line_join(xctx->cairo_save_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(xctx->cairo_save_ctx, CAIRO_LINE_CAP_ROUND);
/***** Create Cairo main drawing window structures *****/
#if HAS_XRENDER==1
#if HAS_XCB==1
dbg(1, "create_cairo_surface: w=%d, h=%d\n", xctx->xrect[0].width, xctx->xrect[0].height);
xctx->cairo_sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn,
screen_xcb, xctx->window, &format_rgb, xctx->xrect[0].width, xctx->xrect[0].height);
#else
xctx->cairo_sfc = cairo_xlib_surface_create_with_xrender_format (display,
xctx->window, DefaultScreenOfDisplay(display), render_format,
xctx->xrect[0].width, xctx->xrect[0].height);
#endif /* HAS_XCB */
#else
xctx->cairo_sfc = cairo_xlib_surface_create(display, xctx->window, visual,
xctx->xrect[0].width, xctx->xrect[0].height);
#endif /* HAS_XRENDER */
if(cairo_surface_status(xctx->cairo_sfc)!=CAIRO_STATUS_SUCCESS) {
fprintf(errfp, "ERROR: invalid cairo surface\n");
}
@ -1553,16 +1517,13 @@ void resetcairo(int create, int clear, int force_or_resize)
cairo_select_font_face(xctx->cairo_ctx, tclgetvar("cairo_font_name"),
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(xctx->cairo_ctx, 20);
cairo_set_font_options(xctx->cairo_ctx, options);
cairo_set_line_width(xctx->cairo_ctx, 1);
cairo_set_line_join(xctx->cairo_ctx, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap(xctx->cairo_ctx, CAIRO_LINE_CAP_ROUND);
#if 0
* #if HAS_XCB==1 && HAS_XRENDER==1
* cairo_xcb_surface_set_size(xctx->cairo_sfc, xctx->xrect[0].width, xctx->xrect[0].height);
* #else
* cairo_xlib_surface_set_size(xctx->cairo_sfc, xctx->xrect[0].width, xctx->xrect[0].height);
* #endif /* HAS_XCB && HAS_XRENDER */
#endif
cairo_font_options_destroy(options);
}
#endif /* HAS_CAIRO */
}
@ -1664,15 +1625,6 @@ int Tcl_AppInit(Tcl_Interp *inter)
int running_in_src_dir;
int fs;
/* XVisualInfo vinfo; */
#if HAS_XCB==1
#if HAS_XRENDER==1
xcb_render_query_pict_formats_reply_t *formats_reply;
xcb_render_pictforminfo_t *formats;
xcb_render_query_pict_formats_cookie_t formats_cookie;
#endif
#endif
/* get PWD and HOME */
if(!getcwd(pwd_dir, PATH_MAX)) {
fprintf(errfp, "Tcl_AppInit(): getcwd() failed\n");
@ -2075,47 +2027,6 @@ int Tcl_AppInit(Tcl_Interp *inter)
dbg(1, "Tcl_AppInit(): top window ID=0x%lx\n",topwindow);
dbg(1, "Tcl_AppInit(): done tkinit()\n");
#if HAS_XCB==1
/* grab an existing xlib connection 20171125 */
xcbconn = XGetXCBConnection(display);
if(xcb_connection_has_error(xcbconn)) {
fprintf(errfp, "Could not connect to X11 server");
return 1;
}
screen_xcb = xcb_setup_roots_iterator(xcb_get_setup(xcbconn)).data;
visual_xcb = find_visual(xcbconn, screen_xcb->root_visual);
if(!visual_xcb) {
fprintf(errfp, "got NULL (xcb_visualtype_t)visual");
return 1;
}
#if HAS_XRENDER==1
/*/--------------------------Xrender xcb stuff------- */
formats_cookie = xcb_render_query_pict_formats(xcbconn);
formats_reply = xcb_render_query_pict_formats_reply(xcbconn, formats_cookie, 0);
formats = xcb_render_query_pict_formats_formats(formats_reply);
for (i = 0; i < formats_reply->num_formats; i++) {
/* fprintf(errfp, "i=%d depth=%d type=%d red_shift=%d\n", i,
formats[i].depth, formats[i].type, formats[i].direct.red_shift); */
if (formats[i].direct.red_mask != 0xff &&
formats[i].direct.red_shift != 16)
continue;
if (formats[i].type == XCB_RENDER_PICT_TYPE_DIRECT &&
formats[i].depth == 24 && formats[i].direct.red_shift == 16)
format_rgb = formats[i];
if (formats[i].type == XCB_RENDER_PICT_TYPE_DIRECT &&
formats[i].depth == 32 &&
formats[i].direct.alpha_mask == 0xff &&
formats[i].direct.alpha_shift == 24)
format_rgba = formats[i];
}
free(formats_reply); /* can not use my_free() since not allocated by my_* allocator wrappers */
formats_reply = NULL;
#endif /* HAS_XRENDER */
/*/---------------------------------------------------- */
/* /20171125 */
#endif /*HAS_XCB */
screen_number = Tk_ScreenNumber(mainwindow);
colormap = Tk_Colormap(mainwindow);
screendepth = Tk_Depth(mainwindow);
@ -2137,9 +2048,6 @@ int Tcl_AppInit(Tcl_Interp *inter)
dbg(1, "Tcl_AppInit(): done step e of xinit()\n");
/* xctx->save_pixmap must be created as resetwin() frees it before recreating with new size. */
#if HAS_XRENDER==1
render_format = XRenderFindStandardFormat(display, PictStandardRGB24);
#endif
resetwin(1, 0, 1, 0, 0);
#if HAS_CAIRO==1
/* load font from tcl 20171112 */

View File

@ -79,9 +79,6 @@
/* #include <sys/time.h> for gettimeofday(). use time() instead */
#include <signal.h>
#ifdef __unix__
#if HAS_XRENDER==1
#include <X11/extensions/Xrender.h>
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysymdef.h>
@ -104,19 +101,10 @@ extern char win_temp_dir[PATH_MAX];
#define xftell _ftelli64
#endif
#if HAS_XCB==1
#include <xcb/render.h>
#include <X11/Xlib-xcb.h>
#endif
#if HAS_CAIRO==1
#include <cairo.h>
#include <cairo-xlib.h>
#include "cairo-xlib-xrender.h"
#if HAS_XCB==1
#include <cairo-xcb.h>
#endif
#endif
#include <tcl.h>
@ -943,17 +931,6 @@ extern int screen_number;
extern int screendepth;
extern Pixmap cad_icon_pixmap, cad_icon_mask, *pixmap;
extern Visual *visual;
#if HAS_XRENDER==1
extern XRenderPictFormat *render_format;
#endif
#if HAS_XCB==1
extern xcb_connection_t *xcbconn;
extern xcb_screen_t *screen_xcb;
#if HAS_XRENDER==1
extern xcb_render_pictforminfo_t format_rgb, format_rgba;
#endif
extern xcb_visualtype_t *visual_xcb;
#endif /* HAS_XCB */
/*********** These variables are mirrored in tcl code ***********/
extern int cadlayers;