From bb64297b6e928a06d814cc8e58e8e1a774994b22 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Mon, 7 Dec 2020 20:04:57 +0100 Subject: [PATCH] better #if/#endif configuration of various xrender/xcb/cairo combinations --- src/actions.c | 14 +++++++------- src/draw.c | 30 +++++++++++++++--------------- src/editprop.c | 14 +++++++------- src/findnet.c | 6 +++--- src/globals.c | 4 ++-- src/move.c | 32 ++++++++++++++++---------------- src/psprint.c | 2 +- src/scheduler.c | 2 +- src/select.c | 34 +++++++++++++++++----------------- src/svgdraw.c | 2 +- src/xinit.c | 11 +++++++---- src/xschem.h | 24 ++++++++++++++++-------- 12 files changed, 93 insertions(+), 82 deletions(-) diff --git a/src/actions.c b/src/actions.c index 155cea03..6411e6cc 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1185,7 +1185,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected) xRect tmp; int c, i; int count=0; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif @@ -1276,7 +1276,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected) { if(selected == 1 && !xctx->text[i].sel) continue; if(selected == 2) continue; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif if(text_bbox(xctx->text[i].txt_ptr, xctx->text[i].xscale, @@ -1287,7 +1287,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected) count++; updatebbox(count,boundbox,&tmp); } - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif } @@ -2015,7 +2015,7 @@ void new_polygon(int what) } } -#ifdef HAS_CAIRO +#if HAS_CAIRO==1 int text_bbox(const char *str, double xscale, double yscale, short rot, short flip, int hcenter, int vcenter, double x1,double y1, double *rx1, double *ry1, double *rx2, double *ry2) @@ -2162,7 +2162,7 @@ void place_text(int draw_text, double mx, double my) const char *str; int save_draw; xText *t = &xctx->text[xctx->texts]; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 char *textfont; #endif @@ -2216,7 +2216,7 @@ void place_text(int draw_text, double mx, double my) my_strdup(21, &t->font, get_tok_value(t->prop_ptr, "font", 0)); textlayer = t->layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 textfont = t->font; if((textfont && textfont[0]) || t->flags) { cairo_font_slant_t slant; @@ -2238,7 +2238,7 @@ void place_text(int draw_text, double mx, double my) draw_string(textlayer, NOW, t->txt_ptr, 0, 0, t->hcenter, t->vcenter, t->x0,t->y0, t->xscale, t->yscale); } draw_window = save_draw; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if((textfont && textfont[0]) || t->flags) { cairo_restore(xctx->cairo_ctx); cairo_restore(xctx->cairo_save_ctx); diff --git a/src/draw.c b/src/draw.c index 3fe7a681..e8b38cf8 100644 --- a/src/draw.c +++ b/src/draw.c @@ -107,7 +107,7 @@ void print_image() #endif XSetTile(display, xctx->gctiled, xctx->save_pixmap); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 cairo_destroy(xctx->cairo_save_ctx); cairo_surface_destroy(xctx->cairo_save_sfc); @@ -183,7 +183,7 @@ void print_image() XSetTile(display, xctx->gctiled, xctx->save_pixmap); -#ifdef HAS_CAIRO +#if HAS_CAIRO==1 cairo_destroy(xctx->cairo_save_ctx); cairo_surface_destroy(xctx->cairo_save_sfc); @@ -223,7 +223,7 @@ void print_image() } -#ifdef HAS_CAIRO +#if HAS_CAIRO==1 void set_cairo_color(int layer) { cairo_set_source_rgb(xctx->cairo_ctx, @@ -264,7 +264,7 @@ int set_text_custom_font(xText *txt) #endif -#ifdef HAS_CAIRO +#if HAS_CAIRO==1 static void cairo_draw_string_line(cairo_t *c_ctx, char *s, double x, double y, short rot, short flip, int lineno, double fontheight, double fontascent, double fontdescent, int llength) @@ -472,7 +472,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, register xSymbol *symptr; int textlayer; double angle; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 char *textfont; #endif if(xctx->inst[n].ptr == -1) return; @@ -589,7 +589,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, if(textlayer < 0 || textlayer >= cadlayers) textlayer = c; } if((c == PINLAYER && xctx->inst[n].flags & 4) || enable_layer[textlayer]) { - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 textfont = symptr->text[j].font; if((textfont && textfont[0]) || symptr->text[j].flags) { cairo_font_slant_t slant; @@ -611,11 +611,11 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, (text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3, flip^text.flip, text.hcenter, text.vcenter, x0+x1, y0+y1, text.xscale, text.yscale); - #ifndef HAS_CAIRO + #if HAS_CAIRO==0 drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0); drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0); #endif - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if( (textfont && textfont[0]) || symptr->text[j].flags) { cairo_restore(xctx->cairo_ctx); cairo_restore(xctx->cairo_save_ctx); @@ -641,7 +641,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot register xSymbol *symptr; double angle; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif @@ -736,13 +736,13 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot if(text.xscale*FONTWIDTH*xctx->mooz<1) continue; txtptr= translate(n, text.txt_ptr); ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&text); #endif if(txtptr[0]) draw_temp_string(gc, what, txtptr, (text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3, flip^text.flip, text.hcenter, text.vcenter, x0+x1, y0+y1, text.xscale, text.yscale); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif @@ -1559,7 +1559,7 @@ void draw(void) register xSymbol *symptr; int textlayer; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 char *textfont; #endif @@ -1725,7 +1725,7 @@ void draw(void) textlayer = xctx->text[i].layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; dbg(1, "draw(): drawing string %d = %s\n",i, xctx->text[i].txt_ptr); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(!enable_layer[textlayer]) continue; textfont = xctx->text[i].font; if( (textfont && textfont[0]) || xctx->text[i].flags) { @@ -1748,13 +1748,13 @@ void draw(void) xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0,xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if((textfont && textfont[0]) || xctx->text[i].flags ) { cairo_restore(xctx->cairo_ctx); cairo_restore(xctx->cairo_save_ctx); } #endif - #ifndef HAS_CAIRO + #if HAS_CAIRO==0 drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0); drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0); #endif diff --git a/src/editprop.c b/src/editprop.c index 11957dbf..8f1c9a99 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -702,7 +702,7 @@ void edit_polygon_property(void) /* x=0 use text widget x=1 use vim editor */ void edit_text_property(int x) { - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif int sel, k, text_changed; @@ -756,14 +756,14 @@ void edit_text_property(int x) rot = xctx->text[sel].rot; /* calculate bbox, some cleanup needed here */ flip = xctx->text[sel].flip; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[sel]); #endif text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale, xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0, &xx1,&yy1,&xx2,&yy2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif @@ -777,14 +777,14 @@ void edit_text_property(int x) for(l=0;lrect[PINLAYER][l].prop_ptr, "name",0)), xctx->text[sel].txt_ptr) ) { - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[sel]); #endif text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale, xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0, &xx1,&yy1,&xx2,&yy2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif @@ -841,14 +841,14 @@ void edit_text_property(int x) } /* calculate bbox, some cleanup needed here */ - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[sel]); #endif text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale, xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0, &xx1,&yy1,&xx2,&yy2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif diff --git a/src/findnet.c b/src/findnet.c index 9f2ed85a..9050e36b 100644 --- a/src/findnet.c +++ b/src/findnet.c @@ -275,21 +275,21 @@ void find_closest_text(double mx,double my) double xx1,xx2,yy1,yy2; int i,r=-1; double threshold = CADWIREMINDIST * CADWIREMINDIST * cadgrid * cadgrid / 400; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif for(i=0;itexts;i++) { rot = xctx->text[i].rot; flip = xctx->text[i].flip; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif text_bbox(xctx->text[i].txt_ptr, xctx->text[i].xscale, xctx->text[i].yscale, rot, flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, &xx1,&yy1, &xx2,&yy2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif if(POINTINSIDE(mx,my,xx1,yy1, xx2, yy2)) diff --git a/src/globals.c b/src/globals.c index 9b873ed3..9f2078f1 100644 --- a/src/globals.c +++ b/src/globals.c @@ -102,8 +102,9 @@ Pixmap cad_icon_pixmap=0, cad_icon_mask=0; XPoint *gridpoint; /* pointer to array of gridpoints, used in draw() */ XColor xcolor_array[256]; Visual *visual; -#ifdef HAS_CAIRO +#if HAS_XRENDER==1 XRenderPictFormat *render_format; +#endif #if HAS_XCB==1 xcb_connection_t *xcbconn; @@ -111,7 +112,6 @@ xcb_render_pictforminfo_t format_rgb, format_rgba; xcb_screen_t *screen_xcb; xcb_visualtype_t *visual_xcb; #endif /*HAS_XCB */ -#endif /*HAS_CAIRO */ /* these variables are mirrored in tcl code */ int fullscreen=0; diff --git a/src/move.c b/src/move.c index a10efbba..6fa159be 100644 --- a/src/move.c +++ b/src/move.c @@ -186,7 +186,7 @@ void draw_selection(GC g, int interruptable) { int i, c, k, n; double angle; /* arc */ - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif @@ -203,7 +203,7 @@ void draw_selection(GC g, int interruptable) } else { ROTATION(xctx->move_rot, xctx->move_flip, xctx->x1, xctx->y_1, xctx->text[n].x0, xctx->text[n].y0, xctx->rx1,xctx->ry1); } - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[n]); #endif draw_temp_string(g,ADD, xctx->text[n].txt_ptr, @@ -212,7 +212,7 @@ void draw_selection(GC g, int interruptable) xctx->text[n].flip^xctx->move_flip, xctx->text[n].hcenter, xctx->text[n].vcenter, xctx->rx1+xctx->deltax, xctx->ry1+xctx->deltay, xctx->text[n].xscale, xctx->text[n].yscale); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif @@ -502,7 +502,7 @@ void copy_objects(int what) const char *str; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 char *textfont; /* int customfont; */ #endif @@ -781,14 +781,14 @@ void copy_objects(int what) if(k!=TEXTLAYER) break; check_text_storage(); /* - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[n]); #endif text_bbox(xctx->text[n].txt_ptr, xctx->text[n].xscale, xctx->text[n].yscale, xctx->text[n].rot,xctx->text[n].flip, xctx->text[n].hcenter, xctx->text[n].vcenter, xctx->text[n].x0, xctx->text[n].y0, &xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif bbox(ADD, xctx->rx1, xctx->ry1, xctx->rx2, xctx->ry2 ); @@ -838,7 +838,7 @@ void copy_objects(int what) textlayer = xctx->text[xctx->texts].layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 textfont = xctx->text[xctx->texts].font; if((textfont && textfont[0]) || xctx->text[xctx->texts].flags) { char *font = xctx->text[xctx->texts].font; @@ -861,11 +861,11 @@ void copy_objects(int what) xctx->text[xctx->texts].hcenter, xctx->text[xctx->texts].vcenter, xctx->rx1+xctx->deltax,xctx->ry1+xctx->deltay, xctx->text[xctx->texts].xscale, xctx->text[xctx->texts].yscale); - #ifndef HAS_CAIRO + #if HAS_CAIRO==0 drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0); drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0); #endif - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if( (textfont && textfont[0]) || xctx->text[xctx->texts].flags) { cairo_restore(xctx->cairo_ctx); cairo_restore(xctx->cairo_save_ctx); @@ -983,11 +983,11 @@ void move_objects(int what, int merge, double dx, double dy) double angle; double tx1,ty1; /* temporaries for swapping coordinates 20070302 */ int textlayer; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 char *textfont; #endif xInstance * const inst = xctx->inst; @@ -1360,13 +1360,13 @@ void move_objects(int what, int merge, double dx, double dy) case xTEXT: if(k!=TEXTLAYER) break; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[n]); #endif text_bbox(xctx->text[n].txt_ptr, xctx->text[n].xscale, xctx->text[n].yscale, xctx->text[n].rot,xctx->text[n].flip, xctx->text[n].hcenter, xctx->text[n].vcenter, xctx->text[n].x0, xctx->text[n].y0, &xctx->rx1,&xctx->ry1, &xctx->rx2,&xctx->ry2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif bbox(ADD, xctx->rx1, xctx->ry1, xctx->rx2, xctx->ry2 ); @@ -1387,7 +1387,7 @@ void move_objects(int what, int merge, double dx, double dy) textlayer = xctx->text[n].layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 textfont = xctx->text[n].font; if((textfont && textfont[0]) || xctx->text[n].flags) { cairo_font_slant_t slant; @@ -1407,11 +1407,11 @@ void move_objects(int what, int merge, double dx, double dy) xctx->text[n].rot, xctx->text[n].flip, xctx->text[n].hcenter, xctx->text[n].vcenter, xctx->text[n].x0, xctx->text[n].y0, xctx->text[n].xscale, xctx->text[n].yscale); - #ifndef HAS_CAIRO + #if HAS_CAIRO==0 drawrect(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0); drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0); #endif - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if( (textfont && textfont[0]) || xctx->text[n].flags) { cairo_restore(xctx->cairo_ctx); cairo_restore(xctx->cairo_save_ctx); diff --git a/src/psprint.c b/src/psprint.c index f88edce6..3aac1630 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -211,7 +211,7 @@ static void ps_draw_string(int gctext, const char *str, int i; if(str==NULL) return; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 text_bbox_nocairo(str, xscale, yscale, rot, flip, hcenter, vcenter, x1,y1, &rx1,&ry1,&rx2,&ry2); #else text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x1,y1, &rx1,&ry1,&rx2,&ry2); diff --git a/src/scheduler.c b/src/scheduler.c index 160bc4db..3d72ed25 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1920,7 +1920,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg my_strncpy(svg_font_name, argv[3], S(svg_font_name)); } } else - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(!strcmp(argv[2],"cairo_font_name")) { if( strlen(argv[3]) < sizeof(cairo_font_name) ) { my_strncpy(cairo_font_name, argv[3], S(cairo_font_name)); diff --git a/src/select.c b/src/select.c index 1d8f703b..3f115aeb 100644 --- a/src/select.c +++ b/src/select.c @@ -40,7 +40,7 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2) double xx1,yy1,xx2,yy2; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif /* symbol bbox */ @@ -74,14 +74,14 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2) dbg(2, "symbol_bbox(): translated text: %s\n", tmp_txt); ROTATION(rot, flip, 0.0,0.0,text.x0, text.y0,text_x0,text_y0); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont=set_text_custom_font(&text); #endif text_bbox(tmp_txt, text.xscale, text.yscale, (text.rot + ( (sym_flip && (text.rot & 1) ) ? sym_rot+2 : sym_rot)) &0x3, sym_flip ^ text.flip, text.hcenter, text.vcenter, x0+text_x0,y0+text_y0, &xx1,&yy1,&xx2,&yy2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif if(xx1<*x1) *x1=xx1; @@ -207,7 +207,7 @@ static void del_rect_line_arc_poly(void) void delete(void) { int i, j, n; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif @@ -271,14 +271,14 @@ void delete(void) { select_rot = xctx->text[i].rot; select_flip = xctx->text[i].flip; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif text_bbox(xctx->text[i].txt_ptr, xctx->text[i].xscale, xctx->text[i].yscale, select_rot, select_flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, &xx1,&yy1, &xx2,&yy2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif bbox(ADD, xx1, yy1, xx2, yy2 ); @@ -450,7 +450,7 @@ void bbox(int what,double x1,double y1, double x2, double y2) XSetClipMask(display, gc[i], None); /* 20171110 optimization, clipping already done in software */ XSetClipMask(display, gcstipple[i], None); /* 20171110 optimization, clipping already done in software */ } - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 cairo_reset_clip(xctx->cairo_ctx); cairo_reset_clip(xctx->cairo_save_ctx); #endif @@ -479,7 +479,7 @@ void bbox(int what,double x1,double y1, double x2, double y2) } XSetClipRectangles(display, xctx->gctiled, 0,0, xctx->xrect, 1, Unsorted); dbg(1, "bbox(): bbox= %d %d %d %d\n",xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 cairo_rectangle(xctx->cairo_ctx, xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height); cairo_clip(xctx->cairo_ctx); cairo_rectangle(xctx->cairo_save_ctx, xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height); @@ -495,7 +495,7 @@ void unselect_all(void) { int i,c; char str[PATH_MAX]; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif xctx->ui_state = 0; @@ -528,14 +528,14 @@ void unselect_all(void) if(xctx->text[i].sel == SELECTED) { xctx->text[i].sel = 0; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(& xctx->text[i]); /* needed for bbox calculation */ #endif draw_temp_string(xctx->gctiled,ADD, xctx->text[i].txt_ptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif } @@ -685,7 +685,7 @@ void select_text(int i,unsigned short select_mode, int fast) { char str[1024]; /* overflow safe */ char s[256]; /* overflow safe */ - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif @@ -698,7 +698,7 @@ void select_text(int i,unsigned short select_mode, int fast) } xctx->text[i].sel = select_mode; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif if(select_mode) @@ -711,7 +711,7 @@ void select_text(int i,unsigned short select_mode, int fast) xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif xctx->need_reb_sel_arr=1; @@ -892,7 +892,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /* 201509 int c,i; double x, y, r, a, b, xa, ya, xb, yb; /* arc */ xRect tmp; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 int customfont; #endif @@ -918,7 +918,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /* 201509 { select_rot = xctx->text[i].rot; select_flip = xctx->text[i].flip; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 customfont = set_text_custom_font(&xctx->text[i]); #endif text_bbox(xctx->text[i].txt_ptr, @@ -926,7 +926,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /* 201509 xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, &xx1,&yy1, &xx2,&yy2); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 if(customfont) cairo_restore(xctx->cairo_ctx); #endif if(RECTINSIDE(xx1,yy1, xx2, yy2,x1,y1,x2,y2)) diff --git a/src/svgdraw.c b/src/svgdraw.c index d0eeb907..38f0d6fc 100644 --- a/src/svgdraw.c +++ b/src/svgdraw.c @@ -314,7 +314,7 @@ static void old_svg_draw_string(int layer, const char *str, int i; if(str==NULL) return; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 text_bbox_nocairo(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y, &rx1,&ry1,&rx2,&ry2); #else text_bbox(str, xscale, yscale, rot, flip, hcenter, vcenter, x,y, &rx1,&ry1,&rx2,&ry2); diff --git a/src/xinit.c b/src/xinit.c index 233f36bf..aae8d498 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -425,7 +425,7 @@ void alloc_xschem_data() xctx->inst_color=NULL; xctx->window = xctx->save_pixmap = 0; xctx->xrect[0].width = xctx->xrect[0].height = xctx->xrect[0].x = xctx->xrect[0].y = 0; -#ifdef HAS_CAIRO +#if HAS_CAIRO==1 xctx->cairo_ctx = xctx->cairo_save_ctx = NULL; xctx->cairo_sfc = xctx->cairo_save_sfc = NULL; #endif @@ -895,7 +895,7 @@ void change_linewidth(double w) * and sets some graphical attributes */ void resetcairo(int create, int clear, int force_or_resize) { - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 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 @@ -936,7 +936,6 @@ void resetcairo(int create, int clear, int force_or_resize) xctx->cairo_sfc = cairo_xcb_surface_create_with_xrender_format(xcbconn, screen_xcb, xctx->window, &format_rgb, xctx->xschem_w, xctx->xschem_h); #else - render_format = XRenderFindStandardFormat(display, PictStandardRGB24); xctx->cairo_sfc = cairo_xlib_surface_create_with_xrender_format (display, xctx->window, DefaultScreenOfDisplay(display), render_format, xctx->xschem_w, xctx->xschem_h); #endif /* HAS_XCB */ @@ -1038,10 +1037,12 @@ int Tcl_AppInit(Tcl_Interp *inter) /* 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"); @@ -1411,6 +1412,7 @@ int Tcl_AppInit(Tcl_Interp *inter) 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); @@ -1432,6 +1434,7 @@ int Tcl_AppInit(Tcl_Interp *inter) format_rgba = formats[i]; } my_free(1145, &formats_reply); + #endif /* HAS_XRENDER */ /*/---------------------------------------------------- */ /* /20171125 */ #endif /*HAS_XCB */ @@ -1468,7 +1471,7 @@ int Tcl_AppInit(Tcl_Interp *inter) render_format = XRenderFindStandardFormat(display, PictStandardRGB24); #endif resetwin(1, 0, 1); - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 /* load font from tcl 20171112 */ tcleval("xschem set svg_font_name $svg_font_name"); tcleval("xschem set cairo_font_name $cairo_font_name"); diff --git a/src/xschem.h b/src/xschem.h index 2991ac7b..64529b89 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -76,10 +76,12 @@ #include #include - /* #include for gettimeofday(). use time() instead */ #include #ifdef __unix__ +#if HAS_XRENDER==1 +#include +#endif #include #include #include @@ -102,12 +104,17 @@ extern char win_temp_dir[PATH_MAX]; #define xftell _ftelli64 #endif -#ifdef HAS_CAIRO + +#if HAS_XCB==1 +#include +#include +#endif + +#if HAS_CAIRO==1 #include #include #include "cairo-xlib-xrender.h" #if HAS_XCB==1 -#include #include #endif #endif @@ -533,10 +540,9 @@ typedef struct { Window window; Pixmap save_pixmap; XRectangle xrect[1]; - #ifdef HAS_CAIRO + #if HAS_CAIRO==1 cairo_surface_t *cairo_sfc, *cairo_save_sfc; cairo_t *cairo_ctx, *cairo_save_ctx; - #endif GC gctiled; char *undo_dirname; @@ -771,15 +777,17 @@ extern XPoint *gridpoint; extern Pixmap cad_icon_pixmap, cad_icon_mask, *pixmap; extern XColor xcolor_array[]; extern Visual *visual; -#ifdef HAS_CAIRO +#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 */ -#endif /* HAS_CAIRO */ /* FUNCTIONS */ extern double timer(int start); @@ -842,7 +850,7 @@ extern void hash_wire(int what, int n, int incremental); extern void wirecheck(int k); extern void hash_instances(void); /* 20171203 insert instance bbox in spatial hash table */ -#ifdef HAS_CAIRO +#if HAS_CAIRO==1 extern int text_bbox_nocairo(const char * str,double xscale, double yscale, short rot, short flip, int hcenter, int vcenter, double x1,double y1, double *rx1, double *ry1, double *rx2, double *ry2);