I think that we should start a discussion about this whole drawing code.
Hopefully we end up with a deeper understanding of what should happen here and
will then be able to package it up with a nice and clean call to the backend
and three or four (almost?) correct implementations for this in GSContext,
GSStreamContext and GSCairoContext. But then I may be completely wrong here, as
I really don't understand much of this new code.
What I would like to do is:
- get rid of -guiDrawInRect entirely.
- reinstate caching since currently there is no caching whatsoever.
- possibly switch to the new
drawInRect:fromRect:operation:fraction:respectFlipped:hints: method
Our goal should be for the following cairo calls to be used when drawing an
uncached image:
cairo_surface_t *src = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, [rep
pixelsWide], [rep pixelsHigh]);
// copy the ARGB data in NSBitmapImageRep to the src image surface in BGRA
format
cairo_t *cr = cairo_create(dest);
// set the transformation matrix and clipping rect on cr to refect the source
rect and dest rect
cairo_set_source_surface(cr, src, 0, 0);
cairo_paint(cr);
cairo_destroy(cr);
cairo_surface_destroy(src);
That's it, I think. To do caching, the code is the same except the 'src'
surface is created as an xlib surface so it's stored on the X server, and the
surface is kept around and reused, so the copying from NSBitmapImageRep to
cairo only happens once as long as the cached surface is kept alive.