June 3, 2011

cairo draw over alpha

Hi, I'd like to draw with cairo over a surface of a GtkDrawingArea. My problem is that drawing over the surface doesn't draw a solid color over a color with alpha channel. I don't use any special cairo operators and the result is that I see some unneeded rectangles with alpha channel where there shouldn't be any.

cr = gdk_cairo_create(GTK_WIDGET(editor->drawing_area)->window);

cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
cairo_rectangle(cr, 0.0, 0.0, (double) widget->allocation.width, (double) widget->allocation.height);

/* do some other drawing */

/* draw with alpha channel */
cairo_set_source_rgba(cr, 0.25, 0.5, 1.0, 0.5);
cairo_rectangle(cr, (double) x, (double) y, (double) width, (double) height);

/* pop it to source */

Click Here!