Re: Question about the GdkGC



Tom Liu wrote:

Ok I understand why create GdkGC and use GdkGC both need the GdkDrawable
parameter because one created GC can apply to multiple window.

But how about the performance?

Creating GC for each colour you have to draw is the fastest way, but I'm not sure this is
needed when you drawing some GDK primitives per second.

I saw a program need to draw 10 color on a drawable. They just create 10
GC! And they nevery release these GC.
It this right way to do so? Should I create one GC and change the colors
when need it?

I'd prefer to create a single and change colours. Memory is still not an infinite resource. Just can't imagine the situation when setting colour to GC will be the bottleneck.

I am a windows programmer, usually when I need to draw something in the
window, I just get a gc, change color, draw, change color back, release
gc.

Consider gtk_get_gc(), gtk_release_gc() functions:
http://developer.gnome.org/doc/API/2.0/gtk/gtk-Graphics-Contexts.html

Looks gtk work like this. Create multiple GC, use these when needed over and over again.





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