| It is unlikely that your performance problem is caused by using separate
GCs. In fact, this is probably the best way to do it. You could use a
single GC, and change its colors (foreground/background) dynamically, but
this would only result in more overhead, not less.
Can you describe the performance problems you're having? Does it seem
related to the scrolling or to the drawing? How are you drawing the lines?
Are you calling XDrawPoint, XDrawLine, or what? How are you doing the
scrolling? XCopyArea?
Have you tried doing the same program but (temporarily) have all the draw
operations use the same GC? Of course you won't get multiple colors, but
at least you'll be able to eliminate that factor to narrow down on your
performance problem. If it gets faster, then it may in fact be related
to the multiple GCs. If it is still slow, then we need to look somewhere
else.
Feel free to post some code fragments if you think that would help.
-steve-
|
|
Steve,
The slowdown in performance comes from the difference between using the
X$DRAW_LINE call for each GC and using the X$DRAW_SEGMENTS for
submitting several lines to be drawn in one call. The program segment
here is basically how I tested this difference, and I found that the
X$DRAW_LINE loop took about 10-15% longer than the X$DRAW_SEGMENTS
loop, all things being equal. I haven't gotten into the scrolling
routines yet, but from what I've read, it will probably be using a
X$COPY_AREA call, which will mean separate calls for each GC. I
anticipate a lot of difference here when I need eight calls instead of
one! I guess what I'm looking for is a way to plot in different colors
using the same GC so that when the time comes for scrolling, I'll only
need to do the one 'cut' and 'paste'.
Thanks for replying so fast Steve! I hope the Fortran doesn't scare
you away...
Bill
*R* y_n_colors is set to .FALSE. to run the single-color loop
*R* y_n_colors is set to .TRUE. to run the multi-color loop
*R* Test data is contained in data(1..8,1..1000)
*R* the first argument is the plot number, the second is the data
*R* x_mult, y_mult, window_y_len, num_axis are all used to calculate
*R* the appropriate coordinates for the point to plot
*R* which_axis(1..8) is an array telling which axis a particular plot
*R* will be drawn on (i.e. plots can be drawn on any of 8 axes)
*R* Each array element contains a # from 1-8 telling which axis
*R* that plot will be drawn on.
*R* num_axis is the total number of axes on the screen
DO x_count=1,full_screen
IF (.NOT. y_n_colors) THEN
*R* Single color......
DO plot_count = 1,num_plots
new_y(plot_count) =
1 data(which_plot(plot_count),x_count)
xvlist(plot_count).x$w_gseg_x1 =
1 NINT(x_mult(plot_type) * (x_count - 1) *
1 x_density)
xvlist(plot_count).x$w_gseg_y1 =
1 NINT((0.5 * y_mult(plot_type) * old_y(plot_count)
1 + window_y_len(plot_type) * which_axis(plot_count)) /
1 (num_axis + 1))
xvlist(plot_count).x$w_gseg_x2 =
1 NINT(x_mult(plot_type) * x_count *
1 x_density)
xvlist(plot_count).x$w_gseg_y2 =
1 NINT((0.5 * y_mult(plot_type) * new_y(plot_count)
1 + window_y_len(plot_type) * which_axis(plot_count)) /
1 (num_axis + 1))
old_y(plot_count) = new_y(plot_count)
END DO
*R* Draw batched segments
CALL x$draw_segments( display, window_id, gc_id(1),
1 xvlist,num_plots )
ELSE
*R* Multiple colors......
DO plot_count = 1,num_plots
new_y(plot_count) =
1 data(which_plot(plot_count),x_count)
first_x =
1 NINT(x_mult(plot_type) * (x_count - 1) *
1 x_density)
first_y =
1 NINT((0.5 * y_mult(plot_type) * old_y(plot_count)
1 + window_y_len(plot_type) * which_axis(plot_count)) /
1 (num_axis + 1))
second_x =
1 NINT(x_mult(plot_type) * x_count *
1 x_density)
second_y =
1 NINT((0.5 * y_mult(plot_type) * new_y(plot_count)
1 + window_y_len(plot_type) * which_axis(plot_count)) /
1 (num_axis + 1))
old_y(plot_count) = new_y(plot_count)
*R* Draw a single line
CALL x$draw_line( display, window_id, gc_id(plot_count),
1 first_x,first_y,second_x,second_y )
END DO
END DO
|
| RE .3
You're right, Ken. After some tinkering with X$COPY_AREA, I notice
that it takes not only what was drawn in the GC you specify, but all
graphics within the area.
Thanks for the help.
Bill
|
| It seems that you are drawing all 8 plots at once - drawing
one segment from each plot, and then moving to the second segment from
each plot, and so forth.
If this is true, you should turn your double loop inside-out. Draw all of
the first plot, then all of the second plot, etc. Still use XDrawSegments
(or XDrawLines, which should be even more efficient) for all the segments
comprising a single plot.
Watch out for XLib bugs in calls that pass more
than ??? points - there were problems splitting the request if it
exceeded the maximum transport message length. Stick with, say, 512 points
per requeust and you should not have any trouble.
-steve-
|