Commit 70f4a309 authored by Jeremy Harris's avatar Jeremy Harris

Speedup zoomed drawing by only using subrange of command-list

parent 65e4bfd7
......@@ -247,6 +247,10 @@ enum in_p { NO, YES, MAYBE } in_rect_table[9][9] = {
{ MAYBE, MAYBE, NO, MAYBE, YES, NO, NO, NO, NO }
};
/* set/clear the "mapped" flag on the command
depending on the pl_?_top/bottom rectangle
actually pl->x_left[pl->viewno] etc
*/
static void
compute_window_coords(struct plotter *pl, command *com)
{
......@@ -592,10 +596,14 @@ de_axis(struct plotter * pl)
}
}
void
/* every size-change or box-zoom...
- Regenerate the axis commands
- Set/clear the mapped flags on the commands, depending on the bounding box
*/
static void
size_window(struct plotter *pl)
{
command *c;
command * c, * c_last = NULL;
pl->origin.x = 70;
pl->origin.y = 30;
......@@ -612,8 +620,22 @@ size_window(struct plotter *pl)
compute_window_coords(pl, c);
for (c = pl->label_cmds; c; c = c->next)
compute_window_coords(pl, c);
for (c = first_plain_cmd(pl); c; c = c->next)
for (c = pl->first_mapped_plain[pl->viewno]; c; c = c->next)
{
compute_window_coords(pl, c);
if (c->mapped) break;
}
if (!c) return;
pl->first_mapped_plain[pl->viewno] = c; /* record earliest mapped cmd */
for (c = c->next;
c && c != pl->final_mapped_plain[pl->viewno];
c = c->next)
{
compute_window_coords(pl, c);
c_last = c;
}
pl->final_mapped_plain[pl->viewno] = c_last; /* record last mapped cmd */
}
lXPoint
......@@ -1190,6 +1212,9 @@ undisplay_plotter(plotter * pl, int direction)
/*
* compute the bounding box of the current view
* Used for zoom in and out, and drag
on a zoom or drag button-up, after changing the bounding-box
re-changes the bounding-box
*/
void
shrink_to_bbox(struct plotter *pl, int x, int y)
......@@ -1212,7 +1237,9 @@ shrink_to_bbox(struct plotter *pl, int x, int y)
compute_window_coords(pl, c);
for (c = pl->label_cmds; c; c = c->next)
compute_window_coords(pl, c);
for (c = first_plain_cmd(pl); c; c = c->next)
for (c = pl->first_mapped_plain[pl->viewno];
c && c != pl->final_mapped_plain[pl->viewno];
c = c->next)
compute_window_coords(pl, c);
#ifdef LOTS_OF_DEBUGGING_PRINTS
......@@ -1224,7 +1251,7 @@ shrink_to_bbox(struct plotter *pl, int x, int y)
unparse_coord(pl->y_type, pl_y_top));
#endif
for (c = first_plain_cmd(pl); c; c = c->next)
for (c = pl->first_mapped_plain[pl->viewno]; c; c = c->next)
if (c->mapped)
{
nmapped++;
......@@ -1834,7 +1861,8 @@ plot_and_check(plotter * pl, command * cmd, Display * dpy, Display * dpy2)
/* Return true if we finished the list, false if we were interrupted */
static bool
plot(plotter * pl, command * clist, Display * dpy, Display * dpy2)
plot(plotter * pl, command * clist, command * stop,
Display * dpy, Display * dpy2)
{
command * c;
unsigned decimator;
......@@ -1845,19 +1873,19 @@ plot(plotter * pl, command * clist, Display * dpy, Display * dpy2)
/* plot a quick overview first then fill in later */
for (c = clist, decimator = 0;
c;
c && c != stop;
c = c->next, decimator++, decimator &= ~DECIMATE1)
if (decimator == 0 && c->mapped && c->needs_redraw)
if (!plot_and_check(pl, c, dpy, dpy2)) return FALSE;
for (c = clist, decimator = 0;
c;
c && c != stop;
c = c->next, decimator++, decimator &= ~DECIMATE1)
if ((decimator & (DECIMATE2-1)) == 0 && c->mapped && c->needs_redraw)
if (!plot_and_check(pl, c, dpy, dpy2)) return FALSE;
for (c = clist, decimator = 0;
c;
c && c != stop;
c = c->next, decimator++, decimator &= ~DECIMATE2)
if (decimator != 0 && c->mapped && c->needs_redraw)
if (!plot_and_check(pl, c, dpy, dpy2)) return FALSE;
......@@ -2097,13 +2125,16 @@ main(int argc, char *argv[])
#define ALLPLOTTERS pl = the_plotter_list ; pl != NULL; pl = pl->next
TRACE errprintf("bounding box");
TRACE errprintf("initial bounding box");
for (ALLPLOTTERS) { /* find bounding box */
bool virgin = TRUE;
TRACE avl_dump(pl, pl->commands);
for (c = first_plain_cmd(pl); c; c = c->next) {
pl->first_mapped_plain[0] = first_plain_cmd(pl);
pl->final_mapped_plain[0] = NULL;
for (c = pl->first_mapped_plain[0]; c; c = c->next) {
TRACE errprintf("h %u %s (%s,%s)-(%s,%s)",
c->avl_height, command_name(c),
......@@ -2162,6 +2193,8 @@ main(int argc, char *argv[])
pl_x_right = bump_coord(pl->x_type, pl_x_right);
pl_y_top = bump_coord(pl->y_type, pl_y_top);
pl->first_mapped_plain[pl->viewno+1] = pl->first_mapped_plain[pl->viewno];
pl->final_mapped_plain[pl->viewno+1] = pl->final_mapped_plain[pl->viewno];
pl->viewno += 1;
pl_x_left = pl->x_left[0];
pl_x_right = pl->x_right[0];
......@@ -2211,8 +2244,6 @@ main(int argc, char *argv[])
) {
int visible_count = 0;
for (ALLPLOTTERS) {
command * c_plain_first;
/* if plotter is not yet displayed, do nothing */
if (pl->win == 0) continue;
......@@ -2237,7 +2268,6 @@ main(int argc, char *argv[])
XSetClipRectangles(pl->dpy, pl->gcs[i], 0, 0, xr, 1, YXBanded);
}
c_plain_first = first_plain_cmd(pl);
if (pl->new_expose) {
pl->clean = FALSE;
......@@ -2245,20 +2275,20 @@ main(int argc, char *argv[])
c->needs_redraw = TRUE;
for (c = pl->label_cmds; c; c = c->next) if (c->mapped)
c->needs_redraw = TRUE;
for (c = c_plain_first; c; c = c->next) if (c->mapped) {
c_plain_first = c; /* avoid rescan doing plot() */
break;
}
for ( ; c; c = c->next) if (c->mapped)
c->needs_redraw = TRUE;
for (c = pl->first_mapped_plain[pl->viewno];
c && c != pl->final_mapped_plain[pl->viewno];
c = c->next)
if (c->mapped) c->needs_redraw = TRUE;
pl->new_expose = FALSE;
}
if (pl->visibility != VisibilityFullyObscured && !pl->clean) {
if ( plot(pl, pl->decoration_cmds, dpy, dpy2)
&& plot(pl, pl->label_cmds, dpy, dpy2)
&& plot(pl, c_plain_first, dpy, dpy2)
if ( plot(pl, pl->decoration_cmds, NULL, dpy, dpy2)
&& plot(pl, pl->label_cmds, NULL, dpy, dpy2)
&& plot(pl, pl->first_mapped_plain[pl->viewno],
pl->final_mapped_plain[pl->viewno], dpy, dpy2)
)
pl->clean = TRUE;
}
......@@ -2663,12 +2693,14 @@ main(int argc, char *argv[])
pl->y_bottom[newviewno] = pl_y_bottom;
pl->y_top[newviewno] = pl_y_top;
}
pl->first_mapped_plain[newviewno] = pl->first_mapped_plain[pl->viewno];
pl->final_mapped_plain[newviewno] = pl->final_mapped_plain[pl->viewno];
pl->viewno = newviewno;
} else {
/* do nothing (don't zoom and don't pop) */
if (0) goto G0093;
}
} else {
} else { /* un-zoom */
command * com;
......@@ -2739,6 +2771,8 @@ main(int argc, char *argv[])
pl->y_bottom[newviewno] = pl_y_bottom;
pl->y_top[newviewno] = pl_y_top;
}
pl->first_mapped_plain[newviewno] = pl->first_mapped_plain[pl->viewno];
pl->final_mapped_plain[newviewno] = pl->final_mapped_plain[pl->viewno];
pl->viewno = newviewno;
if (do_x && !y_synch)
......@@ -2756,6 +2790,11 @@ main(int argc, char *argv[])
{
plotter * savepl = pl;
if (pl->viewno > 1)
{
pl->first_mapped_plain[pl->viewno] = pl->first_mapped_plain[pl->viewno-1];
pl->final_mapped_plain[pl->viewno] = pl->final_mapped_plain[pl->viewno-1];
}
drag_coord(pl->x_type, pl_x_left, pl_x_right,
pl->dragend.x,
pl->dragstart.x,
......
......@@ -138,10 +138,12 @@ typedef struct { int x,y; } lXPoint;
typedef struct plotter {
struct plotter *next;
command *commands;
command *commands; /* avl tree root of plain_cmds */
command *first_plain_cmd;
command *decoration_cmds;
command *label_cmds;
command *first_mapped_plain[NUMVIEWS];
command *final_mapped_plain[NUMVIEWS];
command *decoration_cmds; /* simple list */
command *label_cmds; /* simple list */
coord_type x_type;
coord_type y_type;
char *x_units;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment