Re: Scree Updating - Updating toooo soooow

On 7/26/05, Przemysław Więckowski <przemyslaw wieckowski epf pl> wrote:
  Could you please tell me. What would be faster:  directly putting
prepared pixmap using gdk_draw_drawable(..) as rectangle or drawing
rectangle using gdk_draw_rectangle(..)?? ( i heve't tested it so i ask...)

Your choices are:

1) draw to a pixmap, then send the pixmap to the screen
2) draw to the screen

Either way you have to do the drawing, so 1) will (almost) always be slower.

In fact when you do 2), gtk does 1) for you because it does automatic
double-buffering. When an expose event comes in from the window
system, gtk adds the exposed area to the queue of drawing events to do
for that window.

When gtk delivers "expose_event" to your code, it calculates the
bounding box of all the repaints in the queue, allocates an off-screen
pixmap large enough, and calls "expose_event" with drawing pointing at
the off-screen pixmap. After your expose handler finishes, gtk copies
the offscreen pixmap to the display. This way you don't get any
flashing of the display during repaint.

You can ask gtk not to double-buffer your drawing area, but it will
make your code more complicated and the speed-up you get by turning
double-buffering off may not be significant.


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