Re: Drawing with cairo

Saving the cairo context won't help you for performance of a plot with lots of point. What you may want to do if memory is more available than CPU is to cache the image that you draw on, and then just show the image next time you have an expose event. There might actually be some functionality in gtk to do this automatically...


2008/5/15 Diego A. Fons <diegofons apexar com>:
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.
gtk-list mailing list
gtk-list gnome org

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