Re: Drawing with cairo

Paul Davis wrote:
On Thu, 2008-05-15 at 12:05 -0300, Diego A. Fons wrote:

Like Theodore I'm using gtkmm. This is an extrac of the code which doesn't work:
void Plotter::on_realize( void )
    // Create the GDK window
    refGdkWindow = Gdk::Window::create(get_window(), &attributes,
            GDK_WA_X | GDK_WA_Y);

    // Create Cairo context
    Cairo::RefPtr<Cairo::Context> cr = refGdkWindow->create_cairo_context();

you're all thinking too hard. Cairo drawing contexts are supposed to be
created as necessary. They are cheap. Don't try to cache them. Create
them in an expose handler and get rid of them.

my attitude towards Cairo is to assume that its been handcoded in SSE9
assembler unless i come across particular hotspots.

So you are saying I create the Cairo context in the expose event and don't care about performance of redrawing the whole plot? OK, I'm trying that. I'm also going to try the image buffer approach, it is, drawing in a buffer as a member variable and write the buffer's content to the Cairo context in the expose event.

Still I don't understand why can't get a context and store it in a member variable.

Diego A. Fons.

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