Re: Performance issues of GDK deprecation in favour of Cairo
- From: James Morris <james jwm-art net>
- To: Stefan Kost <ensonic hora-obscura de>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Performance issues of GDK deprecation in favour of Cairo
- Date: Wed, 18 Aug 2010 23:39:00 +0100
On 18 August 2010 15:57, Stefan Kost <ensonic hora-obscura de> wrote:
On 17.08.2010 12:01, James Morris wrote:
I see that some GDK drawing functions and graphics contexts have been
deprecated in favour of using Cairo.
Yesterday I spent a few hours *removing* Cairo code from my fledgling
GTK application and replacing it with gdk_draw_rectangle,
gdk_gc_set_rgb_fg_color, and gdk_gc_set_function. I did this for
I am wondering if my approach to drawing is wrong however and if a
better approach might yield less CPU usage?
It begins with a 33ms timeout. The timeout callback calls
gtk_widget_queue_draw on the window and the drawing area.
Would it be possible to isolate this into a standalone demo. Or could
you point us to the actual code?
The actual code is here:
I'm probably not going to work on it for a while. Probably going to
make the back-end into a library first and then investigate the
possibility of using FLTK.
(Imagine rectangles appearing each time a note is played in a piece of
music and disappearing when that note ends.)
In the expose event callback a linked-list of rectangles is
maintained. Rectangles are added to the list and removed from the list
as notes start and end (The application is an experimental MIDI
sequencer/arpeggiator operating in real time).
Each and every time the expose event callback is called (every 33ms)
the background and the entire list of rectangles is drawn as well as
various maintenance functions performed on the list.
The documentation of gdk_cairo_create seems to suggest this is the
only way of doing it when it says:
"Note that due to double-buffering, Cairo contexts created in a GTK+
expose event handler cannot be cached and reused between different
Is it possible to do this any other way?
My machine is a 64bit 3.0ghz dual core desktop. Using GDK for
drawing, the CPU usage is at worst 5% on both cores. Using Cairo on
the other hand, the CPU usage can reach as much as 20% on both cores.
The project is here: http://github.com/jwm-art-net/BoxySeq
Cairo routines is here:
GDK routines is here:
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
] [Thread Prev