[cairo] Memory mapped image surface?

Ian Britten britten at caris.com
Thu Apr 16 11:44:06 PDT 2009

Hi all,
[ This is sortof a continuation of my "Large Image" questions ]

Is there any support for having an image surface that is memory
mapped?  If there currently isn't any, is there any interest in
supporting it?

My goal is not to memory map specific file formats, but instead
to allow Cairo to (Optionally) use a huge image surface by
paging the unused parts of the image in and out of memory.
Obviously, it'd be slower, but as a user, it would be my choice
to make use of this, where needed/appropriate.

The problem, from what I'm being told by Windows developers, is
that you can't simply map a huge file on Windows.  Instead, you
have to manually call MapViewOfFile()/UnmapViewOfFile() so the
appropriate part/page of the file can be swapped in, at which
time you can then access the desired element.

What I suspect/fear is that the Cairo image surface assumes
that the given char* pointer points to a contiguous, valid,
memory block and that it is free to read/write any byte it
needs at any time (Admittedly, a feasible assumption!).
However, it seems that to do what I'm hoping, I'd need a 'hook'
that is called by Cairo to ensure a specific pixel (or maybe
scanline, or something) is actually swapped in and available
for use.

When looking at some of the other surface types, I saw
references to cairo_read_func_t()/cairo_write_func_t() and
wondered if they were intended to meet this need?
Unfortunately, the image surface doesn't seem to make use of
them ...  :(

Many thanks for any info!

More information about the cairo mailing list