Re: Scree Updating - Updating toooo soooow



Hi,

On 7/26/05, Przemysław Więckowski <przemyslaw wieckowski epf pl> wrote:
  i'm trying write DAQ/Visualisation application using GTk2.x, but i'm
little confused , because i can't obtain satisfied efficiency. I written
sample code to check this usig signals :

"motion_notify_event" to obtain mouse movement and position, and next i
emit "configure_event" where:

Cripes, yes, that will be slow. I think would restructure like this:

- Have something running (perhaps in a thread) which captures your new
data every 50ms. Use it to update your internal model of what the
screen should look like (perhaps an array of x/y positions that should
be drawn).

- Whenever a new version of the model is available, call
gtk_widget_queue_draw() on your drawing area. This will not do any
drawing, it will just queue a draw request.

- In your expose handler, redraw the whole screen. Don't allocate any
pixmaps or anything like that, just draw directly. gtk will do double
buffering for you automatically. Don't do anything in configure either
(except perhaps record the size of the window I guess, if you want to
rescale the display as the window resizes).

- As a possible optimisation (only do this if you have performance
problems), only repaint the lines / rectangles etc. in the exposed
area

John


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]