Re: [gdk;gdkpixbuf] Optimisation. Is it possible?



On Mon, 2005-07-11 at 09:58 +0200, uzytkownik22 gazeta pl wrote:
I'd like to create a lot of images from some values.
Values is in some type of tree (background, what in right upper 
corner, what in ...).
Is it possible to reuse GdkGC for enother GdkDrawable then in 
constructor?

Something like:

G_INLINE GdkGC *return_gc_background1(GdkDrawable *gd) {
  static GdkGC *gc = NULL;
  static GdkColor color;
  if(G_UNLIKLY(!gc)) { //It's used many times but once init.
    gc = gdk_gc_new(gd);
    gdk_color_parse("ff0000", &color); //1
    gdk_gc_set_foreground(gc, &color);
  }
  return gc; //What will be happend if enother GdkDrawable
}

A GdkGC can be used with any drawable with the same depth and
GdkScreen as the one for which is was created.

However, drawing onto a drawable that interprets colors differently
is likely not useful, so you really need the two drawables to have
the same GdkColormap.

Regards,
                                                Owen

P.S.:

 G_INLINE isn't used like that.

 There is no significant value to G_UNLIKELY in this type of code;
   it reduces the readability of your code for a very tiny 
   performance improvement.



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