[Cairo] Generic memory/speed efficient surfaces?
cworth at east.isi.edu
Tue Nov 25 07:39:05 PST 2003
On Nov 24, Andrew Chant wrote:
> I am curious if there is a generic surface which can be created,
> then used for drawing and then eventually applied to a 'real'
> surface with 'cairo_show_surface'.
The only thing we currently have is cairo_surface_create_similar. That
will give you a surface of the same type as an existing surface. So
all it really does for you right now is save a couple of function
calls since you won't have to create your own pixmap.
I'd like to replace this function with something like
cairo_set_target_scratch or cairo_surface_create_scratch which would
also create a compatible surface, but it would be of unspecified
The idea is that cairo should know what surface types are compatible,
fastest, best, whatever. The user just wants to be able to draw
offscreen for a bit.
> It would have the user-space co-ordinate system as its own device
> coordinate system, and allow control over precision.
All currently implemented surfaces have a fixed device pixel
grid. As we implement a PDF backend we may end up with a new
resolution-independent surface that could be used in ways that I think
you are suggesting. This new surface could form the basis of the
metafile-based printing approach that has been discussed before.
> I don't want to use real pixmaps, because it adds unnecessary
> communication with the X server and because (I may be wrong here)
> it will pixelize the image before cairo_show_surface.
I don't understand your communication concerns. As far as
pixelization, you are correct. What I have done in similar code is to
always keep the pixel size of the temporary surfaces aligned with the
target device, (eg. redraw each "icon" when the window resizes).
More information about the cairo