Improve DrawingArea drawing



I'm trying to draw a dinamicaly generated drawing into a Gtk::DrawingArea as fast as is possible.

The drawing stuff is done into a Gdk::Pixmap (a lot of draw_segments) that depents on external information ( a socket, a file... whathever ). On the other hand I've a timer that looks if there is a new image to load (a new pixmap generated), if the pixmap is generated a queue_draw call is done. Last in the on_expose_event we simply do a draw_drawable of the pixmap to the window.

It works quite nice but the speed is slow and the CPU use is enormous.
Currently I draw 3fps of 1280x1024 with a CPU use of 65% on a PIV 2,8Gh and 1,5 Giga of ram and RHEL 4.

If the number of segments to draw is reduced the CPU use goes down a lot and so I can do more fps even with that high resolution.

As the Gdk::Pixmap is a X server side image and the segment number to draw is so high,...

- Is there a way to do all the draw_segments process on a client side image and then give that image to the X server ?

- If is possible, doing this could increase the fps or reduce the CPU use ?

- Or I'm doing all wrong and there is a smarter way to do what I need ( if so how ) ?

Gdk::Image is a client side image but it doesn't have any draw_* function, only access to its pixels, and almost the same for Gdk::Pixbuf.

Ahh, one last thing. About draw_segments :
Could it accept a std::vector<GdkSegment> input instead of GdkSegment[] as other draw_* function do ?

Thanks for any answer.





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