RE: Question about the GdkGC



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?
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 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.

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




-----Original Message-----
From: gtk-app-devel-list-admin gnome org
[mailto:gtk-app-devel-list-admin gnome org] On Behalf Of Tristan Van
Berkom
Sent: Wednesday, November 12, 2003 11:56 AM
To: Tom Liu
Cc: gtk-app-devel-list gnome org
Subject: Re: Question about the GdkGC

Tom Liu wrote:

When I create a GdkGC, I have to give a GdkDrawable to attach this GC,
But when I draw line or rectangle, I still need the GdkDrawable as
parameter.

You need to provide a GdkDrawable so that the GdkGC can reference a
colormap; the colormap is created when you create a GdkDrawable
and; if I'm not mistaken; thats because creating the colormap requires
some knowlage of the rendering architechture (Win or XFree86)
(and thats handled at the GdkDrawable level).

Is these because one GdkGC can work on multile GdkDrawable after it
created?
 

Yes it can.

Another question: the CreateGC and releaseGC is a expensive job? Should
I create and release it every time I need to draw or just keep a global
copy for better performance.
 

A GdkGC is like a structure that holds a bunch of paramaters
to draw with when using any GdkDrawables; instead of passing
alot of arguments to the drawing functions; the arguments that
probably won't change from one function call to the next; are
stored in the graphics context.

Does that help ?

Regards,
                                                -Tristan

-- 
"Life would be so much easier if we could just look at the source code."
        -- Francois Baumier



_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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