[cairo] API Shakeup: cairo_<device>_surface_mark_dirty

Carl Worth cworth at cworth.org
Tue Feb 22 14:35:54 PST 2005


It has been noted that the current software fallbacks in cairo are
obsessively correct (and consequently, horrifically slow).

The issue is that the current fallbacks are paranoid and assume
nothing about what happens to surface contents between cairo drawing
operations. In the off chance that some means external to cairo has
been used to draw to the surface, cairo does a fetch, draw, store
cycle with every fallback operation.

In order to fix this, we propose that the user bear the burden of
informing cairo whenever a surface has been modified through external
means. The following function is proposed:

	void
	cairo_<device>_surface_mark_dirty (cairo_surface_t *surface,
					   int x, int y,
					   int width, int height);

This is a device-specific backend function, as device-specific means
must be used to draw externally to the surface, and some devices
(eg. PDF surfaces) do not support external drawing. So, the function
should appear for image surfaces, and all display device surfaces. So,
that gives us the following new functions as of today:

	cairo_image_surface_mark_dirty
	cairo_glitz_surface_mark_dirty
	cairo_quartz_surface_mark_dirty
	cairo_win32_surface_mark_dirty
	cairo_xcb_surface_mark_dirty
	cairo_xlib_surface_mark_dirty

The implementation will be changed to initially assume that the entire
surface is dirty. Any drawing operation subtracts from the dirty
region, while calls to mark_dirty add to it. The image fallbacks will
never need to fetch more than the dirty region.

And the implementation can be optimized to notice when a drawing
operation is independent of the original contents of the surface. For
example, the common case of initially erasing the entire surface:

	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
	cairo_paint (cr);

should clear the dirty region completely without ever having to fetch
anything from the surface.

-Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050222/9e8b9e12/attachment.pgp


More information about the cairo mailing list