cairocontext inside gtkobjects



Hi,

I would be very grateful if someone could shed some light in several
CairoContext problems I'm having. Maybe I should send this cairo list
but I would like to know first if it's someway related to cairo
integration in gdk.

First one:

I have a GTKDrawindArea derived class that draws its background using
cairo. At first I thought it would be a waste of time to create and
destroy the cairo context every time the expose event should be called.
So I decided to create the cairocontext of first expose event invocation
and cache it to reuse in following expose events.

By the way it doesn't work. First expose event works nice and I get a
nice looking background, but following expose events only get a grey
background, though they are executing the same code. The only difference
is the cached cairocontext. 

Then I decided to create and destroy the cairocontext at each expose
event and this works right. All expose events get a nicely background.

Which could be the reasons so the cairocontext can't be cached?

By the way, why is my expose event being called twice each time?


Second one:

Then I created a GtkInvisible derived class. I want this so each
instance keeps track of mouse movement. Though it's a GtkInvisible
derived class, I have encapsulated a Drawing method that I call from the
expose event of the GtkDrawingArea derived class above. This method has
only one input param, that is, the CairoContext used to draw the
background of the GtkDrawingArea derived instance. 

If I only have one instance of GtkInvisible it works nice, and I can
draw from the GtkInvisible into the CairoContext of the GtkDrawingArea
instance.

But if I have 2 or more GTkInvisible instances, only the last one gets
drawed into the cairocontext. The previous ones get no output.

Moreover, the program aborts not predecibly when I have between 3 and 5
instances of the GtkInvisible derived class with this message:

"cairo-gstate.c:240: _cairo_gstate_clone: Assertion `other != ((void
*)0)' failed."

The backtrace is as follows:

#0  0xb77889dc in memcpy () from /lib/tls/i686/cmov/libc.so.6
#1  0xb7b13df4 in cairo_scaled_font_get_font_options ()
   from /usr/lib/libcairo.so.2
#2  0xb7b0a0e6 in cairo_font_options_get_hint_metrics ()
   from /usr/lib/libcairo.so.2
#3  0xb7b059f6 in cairo_save () from /usr/lib/libcairo.so.2

Any idea? By the way, I'm not using any cairo text or font related
functions, neither am I initializing the cairo text layout system.

Please forgive me for this so long email. Any info will be welcomed.
Thanks in advance.




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