diff --git a/src/actions.c b/src/actions.c index 213d8964..ad68be28 100644 --- a/src/actions.c +++ b/src/actions.c @@ -570,13 +570,36 @@ void remove_symbols(void) dbg(1, "remove_symbols(): done\n"); } + +/* set cached rect .flags bitmask based on attributes, currently: + * graph 1 + * graph_unlocked 1 + 2 + * image 1024 + * image_unscaled 1024 + 2048 + */ +int set_rect_flags(xRect *r) +{ + const char *flags; + unsigned short f = 0; + if(r->prop_ptr && r->prop_ptr[0]) { + flags = get_tok_value(r->prop_ptr,"flags",0); + if(strstr(flags, "unscaled")) f |= 3072; + else if(strstr(flags, "image")) f |= 1024; + else if(strstr(flags, "unlocked")) f |= 3; + else if(strstr(flags, "graph")) f |= 1; + } + r->flags = f; + return f; +} + /* what: * 2: copy: drptr->extraptr <- srptr->extraptr * 1: create * 0: clear */ -int setup_rect_extraptr(int what, xRect *drptr, xRect *srptr) +int set_rect_extraptr(int what, xRect *drptr, xRect *srptr) { + #if HAS_CAIRO==1 if(what==2) { /* copy */ if(drptr->flags & 1024) { /* embedded image */ xEmb_image *d, *s; @@ -602,13 +625,12 @@ int setup_rect_extraptr(int what, xRect *drptr, xRect *srptr) if(drptr->flags & 1024) { /* embedded image */ if(drptr->extraptr) { xEmb_image *d = drptr->extraptr; - #if HAS_CAIRO==1 if(d->image) cairo_surface_destroy(d->image); - #endif my_free(1476, &drptr->extraptr); } } } + #endif return 0; } @@ -654,7 +676,7 @@ void clear_drawing(void) for(j=0;jrects[i];j++) { my_free(700, &xctx->rect[i][j].prop_ptr); - setup_rect_extraptr(0, &xctx->rect[i][j], NULL); + set_rect_extraptr(0, &xctx->rect[i][j], NULL); } for(j=0;jarcs[i];j++) { diff --git a/src/draw.c b/src/draw.c index ec577fd2..876c0116 100644 --- a/src/draw.c +++ b/src/draw.c @@ -2569,6 +2569,7 @@ typedef struct } png_to_byte_closure_t; +#if HAS_CAIRO==1 static cairo_status_t png_reader(void *in_closure, unsigned char *out_data, unsigned int length) { png_to_byte_closure_t *closure = (png_to_byte_closure_t *) in_closure; @@ -2590,6 +2591,7 @@ static cairo_status_t png_writer(void *in_closure, const unsigned char *in_data, closure->pos += length; return CAIRO_STATUS_SUCCESS; } +#endif int draw_images_all(void) { @@ -2627,7 +2629,7 @@ int draw_images_all(void) if(RECT_OUTSIDE(sx1, sy1, sx2, sy2, xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2)) continue; if(!r->extraptr) { - setup_rect_extraptr(1, r, NULL); + set_rect_extraptr(1, r, NULL); } emb_ptr = r->extraptr; cairo_save(xctx->cairo_ctx); @@ -2763,7 +2765,11 @@ void draw(void) } if(xctx->enable_layer[c]) for(i=0;irects[c];i++) { xRect *r = &xctx->rect[c][i]; + #if HAS_CAIRO==1 if(c != GRIDLAYER || !(r->flags & (1 + 1024)) ) { + #else + if(c != GRIDLAYER || !(r->flags & 1) ) { + #endif drawrect(c, ADD, r->x1, r->y1, r->x2, r->y2, r->dash); filledrect(c, ADD, r->x1, r->y1, r->x2, r->y2); } diff --git a/src/editprop.c b/src/editprop.c index 19b8e84c..ef5fff6f 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -436,7 +436,7 @@ static void edit_rect_property(int x) set_rect_flags(&xctx->rect[c][n]); /* set cached .flags bitmask from on attributes */ if(xctx->rect[c][n].extraptr) { /* used for images, clear so will be recreated from image attr */ - setup_rect_extraptr(0, &xctx->rect[c][n], NULL); + set_rect_extraptr(0, &xctx->rect[c][n], NULL); } dash = get_tok_value(xctx->rect[c][n].prop_ptr,"dash",0); if( strcmp(dash, "") ) { diff --git a/src/in_memory_undo.c b/src/in_memory_undo.c index 750cc9bf..dd15ecbb 100644 --- a/src/in_memory_undo.c +++ b/src/in_memory_undo.c @@ -308,7 +308,7 @@ void mem_push_undo(void) xctx->uslot[slot].bptr[c][i].prop_ptr = NULL; my_strdup(185, &xctx->uslot[slot].bptr[c][i].prop_ptr, xctx->rect[c][i].prop_ptr); if(xctx->rect[c][i].extraptr) { - setup_rect_extraptr(2, &xctx->uslot[slot].bptr[c][i], &xctx->rect[c][i]); + set_rect_extraptr(2, &xctx->uslot[slot].bptr[c][i], &xctx->rect[c][i]); } } /* arcs */ @@ -533,7 +533,7 @@ void mem_pop_undo(int redo, int set_modify_status) xctx->rect[c][i].prop_ptr = NULL; my_strdup(205, &xctx->rect[c][i].prop_ptr, xctx->uslot[slot].bptr[c][i].prop_ptr); if(xctx->uslot[slot].bptr[c][i].extraptr) { - setup_rect_extraptr(2, &xctx->rect[c][i], &xctx->uslot[slot].bptr[c][i]); + set_rect_extraptr(2, &xctx->rect[c][i], &xctx->uslot[slot].bptr[c][i]); } } /* arcs */ diff --git a/src/move.c b/src/move.c index 6835164f..ebbb5b4b 100644 --- a/src/move.c +++ b/src/move.c @@ -145,7 +145,7 @@ void check_collapsing_objects() if(xctx->rect[c][i].x1==xctx->rect[c][i].x2 || xctx->rect[c][i].y1 == xctx->rect[c][i].y2) { my_free(815, &xctx->rect[c][i].prop_ptr); - setup_rect_extraptr(0, &xctx->rect[c][i], NULL); + set_rect_extraptr(0, &xctx->rect[c][i], NULL); found=1; j++; continue; @@ -874,7 +874,7 @@ void copy_objects(int what) xctx->rx2+xctx->deltax, xctx->ry2+xctx->deltay,xRECT, c, SELECTED, xctx->rect[c][n].prop_ptr); l = xctx->rects[c] - 1; if(xctx->rect[c][n].extraptr) { - setup_rect_extraptr(2, &xctx->rect[c][l], &xctx->rect[c][n]); + set_rect_extraptr(2, &xctx->rect[c][l], &xctx->rect[c][n]); } bbox(ADD, xctx->rect[c][l].x1, xctx->rect[c][l].y1, xctx->rect[c][l].x2, xctx->rect[c][l].y2); break; diff --git a/src/save.c b/src/save.c index 058a95a6..9e4661fe 100644 --- a/src/save.c +++ b/src/save.c @@ -781,27 +781,6 @@ static void load_arc(FILE *fd) xctx->arcs[c]++; } -/* set cached rect .flags bitmask based on attributes, currently: - * graph 1 - * graph_unlocked 1 + 2 - * image 1024 - * image_unscaled 1024 + 2048 - */ -int set_rect_flags(xRect *r) -{ - const char *flags; - unsigned short f = 0; - if(r->prop_ptr && r->prop_ptr[0]) { - flags = get_tok_value(r->prop_ptr,"flags",0); - if(strstr(flags, "unscaled")) f |= 3072; - else if(strstr(flags, "image")) f |= 1024; - else if(strstr(flags, "unlocked")) f |= 3; - else if(strstr(flags, "graph")) f |= 1; - } - r->flags = f; - return f; -} - static void load_box(FILE *fd) { int i,n,c; diff --git a/src/select.c b/src/select.c index 8327cc65..1e3fbd6f 100644 --- a/src/select.c +++ b/src/select.c @@ -218,7 +218,7 @@ static void del_rect_line_arc_poly(void) j++; bbox(ADD, xctx->rect[c][i].x1, xctx->rect[c][i].y1, xctx->rect[c][i].x2, xctx->rect[c][i].y2); my_free(928, &xctx->rect[c][i].prop_ptr); - setup_rect_extraptr(0, &xctx->rect[c][i], NULL); + set_rect_extraptr(0, &xctx->rect[c][i], NULL); set_modify(1); continue; } diff --git a/src/xschem.h b/src/xschem.h index d548b291..3661b6a5 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -395,10 +395,12 @@ typedef struct short bus; } xLine; +#if HAS_CAIRO==1 typedef struct { cairo_surface_t *image; } xEmb_image; +#endif typedef struct { @@ -999,7 +1001,7 @@ extern Xschem_ctx *xctx; /* FUNCTIONS */ extern int set_rect_flags(xRect *r); -extern int setup_rect_extraptr(int what, xRect *drptr, xRect *srptr); +extern int set_rect_extraptr(int what, xRect *drptr, xRect *srptr); extern unsigned char *base64_decode(const char *data, size_t input_length, size_t *output_length); extern char *base64_encode(const unsigned char *data, size_t input_length, size_t *output_length); extern int get_raw_index(const char *node);