[cairo] Cairo dies after drawing a few rectangles...
Jonathan Roewen
jonathan.roewen at gmail.com
Fri Apr 22 03:27:33 PDT 2005
Maybe my implementation is a little naive, but I'm running into a
small problem with cairo and implementing a GUI on top of it.
For now, I'm rendering straight to the video buffer through a cairo
[image] surface. Anyways, after drawing a shape a dozen times, it just
dies. There's a noticable delay on the last redraw or two where it's
slows down a lot.
Anyways, my basic test case is something like:
let test_event () =
if !focus then
button_unfocused ()
else
button_focused ();
focus := not !focus;
(* heh, need to do redraw =) *)
draw button
let draw_shape shape fill stroke =
let cr = CairoGraphics.screen () in
Cairo.save cr;
Cairo.new_path cr;
begin match shape with
| Rectangle (x,y,w,h) ->
Cairo.rectangle cr (float x) (float y) (float w) (float h)
Now I know some of the code is missing, but basically 'draw' calls
'draw_shape' fairly directly. The rest of the code then fills the
shape, then strokes it. It's all fairly trivial stuff.
All button_focused() does is change some variables for stroking the
outline of the rectangle button (just the colour).
Anyways, I have the test_event hooked up to key presses, so each key
press, it changes state of my button graphic. Now, from above, all I
do is draw a new rectangle, fill it, and stroke it. So, can someone
please explain why cairo seems to have trouble dealing with what would
otherwise seem quite straightforward, innocent code.
Jonathan
More information about the cairo
mailing list