avoid unneeded calls to draw_crosshair(1) if crosshair is not enabled. Double performance of draw_graph_points() (do not draw on xctx->window if XCopyArea drawing model (now the default) is enabled

This commit is contained in:
stefan schippers 2024-11-27 16:13:48 +01:00
parent ca6fb60ce7
commit b642d63215
2 changed files with 8 additions and 4 deletions

View File

@ -33,6 +33,7 @@ static int waves_selected(int event, KeySym key, int state, int button)
int is_inside = 0, skip = 0;
static unsigned int excl = STARTZOOM | STARTRECT | STARTLINE | STARTWIRE |
STARTPAN | STARTSELECT | STARTMOVE | STARTCOPY;
int draw_xhair = tclgetboolvar("draw_crosshair");
rstate = state; /* rstate does not have ShiftMask bit, so easier to test for KeyPress events */
rstate &= ~ShiftMask; /* don't use ShiftMask, identifying characters is sifficient */
if(xctx->ui_state & excl) skip = 1;
@ -63,12 +64,12 @@ static int waves_selected(int event, KeySym key, int state, int button)
);
if( (xctx->ui_state & GRAPHPAN) || check) {
is_inside = 1;
draw_crosshair(1);
if(draw_xhair) draw_crosshair(1);
tclvareval(xctx->top_path, ".drw configure -cursor tcross" , NULL);
}
}
if(!is_inside) {
if(tclgetboolvar("draw_crosshair"))
if(draw_xhair)
tclvareval(xctx->top_path, ".drw configure -cursor none" , NULL);
else
tclvareval(xctx->top_path, ".drw configure -cursor {}" , NULL);

View File

@ -2671,6 +2671,7 @@ static void draw_graph_bus_points(const char *ntok, int n_bits, SPICE_DATA **idx
XSetLineAttributes(display, xctx->gc[p], XLINEWIDTH(xctx->lw), LineSolid, LINECAP , LINEJOIN);
}
}
#define MAX_POLY_POINTS 4096*16
/* wcnt is the nth wave in graph, idx is the index in spice raw file */
static void draw_graph_points(int idx, int first, int last,
@ -2721,7 +2722,10 @@ static void draw_graph_points(int idx, int first, int last,
poly_npoints++;
}
set_thick_waves(1, wcnt, wave_col, gr);
for(x = 0; x < 2; x++) {
/* if XCopyArea drawing model is enable no need to draw on window
* |
* \|/ */
for(x = (xctx->draw_window ? 0 : 1); x < 2; x++) {
Drawable w;
int offset = 0, size;
XPoint *pt = point;
@ -4945,7 +4949,6 @@ void MyXCopyAreaDouble(Display* display, Drawable src, Drawable dest, GC gc,
width = (unsigned int)isx2 - (unsigned int)isx1;
height = (unsigned int)isy2 - (unsigned int)isy1;
dbg(1, "%g %g %g %g --> %g %g\n", isx1, isy1, isx2, isy2, idx1, idy1);
#if !defined(__unix__)
XCopyArea(display, src, dest, gc, (int)isx1, (int)isy1, width, height, (int)idx1, (int)idy1);
#if HAS_CAIRO==1