optimization: split cairo font creation into create + set
This commit is contained in:
parent
383dc03696
commit
75fbb76543
|
|
@ -2623,8 +2623,10 @@ int place_text(int draw_text, double mx, double my)
|
|||
if(t->flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
|
||||
cairo_save(xctx->cairo_ctx);
|
||||
cairo_save(xctx->cairo_save_ctx);
|
||||
cairo_select_font_face (xctx->cairo_ctx, textfont, slant, weight);
|
||||
cairo_select_font_face (xctx->cairo_save_ctx, textfont, slant, weight);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create(textfont, slant, weight);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
}
|
||||
#endif
|
||||
save_draw=xctx->draw_window;
|
||||
|
|
|
|||
|
|
@ -324,8 +324,10 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
|
|||
#if HAS_CAIRO==1
|
||||
cairo_save(xctx->cairo_ctx);
|
||||
cairo_save(xctx->cairo_save_ctx);
|
||||
cairo_select_font_face(xctx->cairo_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_select_font_face(xctx->cairo_save_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create("Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
#endif
|
||||
gr = &xctx->graph_struct;
|
||||
for(i=0; i < xctx->rects[GRIDLAYER]; i++) {
|
||||
|
|
|
|||
46
src/draw.c
46
src/draw.c
|
|
@ -189,7 +189,9 @@ int set_text_custom_font(xText *txt) /* 20171122 for correct text_bbox calculati
|
|||
if(txt->flags & TEXT_ITALIC) slant = CAIRO_FONT_SLANT_ITALIC;
|
||||
if(txt->flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
|
||||
cairo_save(xctx->cairo_ctx);
|
||||
cairo_select_font_face (xctx->cairo_ctx, textfont, slant, weight);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create(textfont, slant, weight);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -584,8 +586,10 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
|
|||
if(symptr->text[j].flags & TEXT_OBLIQUE) slant = CAIRO_FONT_SLANT_OBLIQUE;
|
||||
cairo_save(xctx->cairo_ctx);
|
||||
cairo_save(xctx->cairo_save_ctx);
|
||||
cairo_select_font_face (xctx->cairo_ctx, textfont, slant, weight);
|
||||
cairo_select_font_face (xctx->cairo_save_ctx, textfont, slant, weight);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create(textfont, slant, weight);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
}
|
||||
#endif
|
||||
dbg(1, "drawing string: str=%s prop=%s\n", txtptr, text.prop_ptr);
|
||||
|
|
@ -2345,32 +2349,40 @@ static void draw_graph_variables(int wcnt, int wave_color, int n_nodes, int swee
|
|||
if(yt <= gr->ypos2 && yt >= gr->ypos1) {
|
||||
#if HAS_CAIRO == 1
|
||||
if(gr->hilight_wave == wcnt) {
|
||||
cairo_select_font_face(xctx->cairo_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
|
||||
cairo_select_font_face(xctx->cairo_save_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create("Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
}
|
||||
#endif
|
||||
draw_string(wave_color, NOW, tmpstr, 2, 0, 0, 0,
|
||||
xt, DW_Y(yt), gr->digtxtsizelab, gr->digtxtsizelab);
|
||||
#if HAS_CAIRO == 1
|
||||
if(gr->hilight_wave == wcnt) {
|
||||
cairo_select_font_face(xctx->cairo_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_select_font_face(xctx->cairo_save_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create("Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
#if HAS_CAIRO == 1
|
||||
if(gr->hilight_wave == wcnt) {
|
||||
cairo_select_font_face(xctx->cairo_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
|
||||
cairo_select_font_face(xctx->cairo_save_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create("Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
}
|
||||
#endif
|
||||
draw_string(wave_color, NOW, tmpstr, 0, 0, 0, 0,
|
||||
gr->rx1 + 2 + gr->rw / n_nodes * wcnt, gr->ry1, gr->txtsizelab, gr->txtsizelab);
|
||||
#if HAS_CAIRO == 1
|
||||
if(gr->hilight_wave == wcnt) {
|
||||
cairo_select_font_face(xctx->cairo_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_select_font_face(xctx->cairo_save_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create("Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -2996,8 +3008,10 @@ static void draw_graph_all(int flags)
|
|||
#if HAS_CAIRO==1
|
||||
cairo_save(xctx->cairo_ctx);
|
||||
cairo_save(xctx->cairo_save_ctx);
|
||||
cairo_select_font_face(xctx->cairo_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_select_font_face(xctx->cairo_save_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create("Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
#endif
|
||||
if(xctx->draw_single_layer==-1 || GRIDLAYER == xctx->draw_single_layer) {
|
||||
if(xctx->enable_layer[GRIDLAYER]) for(i = 0; i < xctx->rects[GRIDLAYER]; i++) {
|
||||
|
|
@ -3480,8 +3494,10 @@ void draw(void)
|
|||
|
||||
cairo_save(xctx->cairo_ctx);
|
||||
cairo_save(xctx->cairo_save_ctx);
|
||||
cairo_select_font_face (xctx->cairo_ctx, textfont, slant, weight);
|
||||
cairo_select_font_face (xctx->cairo_save_ctx, textfont, slant, weight);
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create(textfont, slant, weight);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
}
|
||||
#endif
|
||||
draw_string(textlayer, ADD, xctx->text[i].txt_ptr,
|
||||
|
|
|
|||
|
|
@ -508,6 +508,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
|
|||
#if HAS_CAIRO==1
|
||||
xctx->cairo_ctx = xctx->cairo_save_ctx = NULL;
|
||||
xctx->cairo_sfc = xctx->cairo_save_sfc = NULL;
|
||||
xctx->cairo_font = NULL;
|
||||
#endif
|
||||
xctx->gctiled = 0;
|
||||
/* get_unnamed_node() */
|
||||
|
|
@ -1772,11 +1773,12 @@ static void resetcairo(int create, int clear, int force_or_resize)
|
|||
if(cairo_surface_status(xctx->cairo_save_sfc)!=CAIRO_STATUS_SUCCESS) {
|
||||
fprintf(errfp, "ERROR: invalid cairo xcb surface\n");
|
||||
}
|
||||
xctx->cairo_font =
|
||||
cairo_toy_font_face_create(tclgetvar("cairo_font_name"), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
|
||||
xctx->cairo_save_ctx = cairo_create(xctx->cairo_save_sfc);
|
||||
/* cairo_set_antialias (xctx->cairo_save_ctx, CAIRO_ANTIALIAS_NONE); */
|
||||
cairo_select_font_face(xctx->cairo_save_ctx, tclgetvar("cairo_font_name"),
|
||||
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_face(xctx->cairo_save_ctx, xctx->cairo_font);
|
||||
cairo_set_font_size(xctx->cairo_save_ctx, 20);
|
||||
|
||||
cairo_set_font_options(xctx->cairo_save_ctx, options);
|
||||
|
|
@ -1796,8 +1798,7 @@ static void resetcairo(int create, int clear, int force_or_resize)
|
|||
}
|
||||
xctx->cairo_ctx = cairo_create(xctx->cairo_sfc);
|
||||
/* cairo_set_antialias (xctx->cairo_ctx, CAIRO_ANTIALIAS_NONE); */
|
||||
cairo_select_font_face(xctx->cairo_ctx, tclgetvar("cairo_font_name"),
|
||||
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_face(xctx->cairo_ctx, xctx->cairo_font);
|
||||
cairo_set_font_size(xctx->cairo_ctx, 20);
|
||||
|
||||
cairo_set_font_options(xctx->cairo_ctx, options);
|
||||
|
|
|
|||
|
|
@ -830,6 +830,7 @@ typedef struct {
|
|||
#if HAS_CAIRO==1
|
||||
cairo_surface_t *cairo_sfc, *cairo_save_sfc;
|
||||
cairo_t *cairo_ctx, *cairo_save_ctx;
|
||||
cairo_font_face_t *cairo_font;
|
||||
#endif
|
||||
GC gctiled;
|
||||
GC *gc;
|
||||
|
|
|
|||
Loading…
Reference in New Issue