[cairo] Adventures in metasurface land (with a fix even)

Keith Packard keithp at keithp.com
Wed Aug 24 02:00:43 PDT 2005

I was grubbing through the PostScript backend fixing various minor cases
where the image fallback was needed and discovered to my horror that the
fallback image was always rendered at 72dpi.

That's because the device space for PostScript is in points, and so the
meta surface captured all drawing in that space. When replayed againts
the image surface, those coordinates were interpreted in pixels without
any scale factor. So, of course, we got crummy looking 72dpi output.

My first thought was that the meta surface would need to be completely
reworked to handle a scale difference between the meta surface device
space and the target surface device space. What a pain.

My second thought was that we'd have to fallback to the old ugly
bitmaps-only PostScript backend.

Would that it were so simple. The old image-based PostScript backend
suffered from *exactly the same problem* as the device space was again
in points instead of pixels; the image surface was painted as if each
pixel were one point square.

So, the problem was clearly not in the meta-surface code, rather we had
a general problem that the device coordinate space provided to users
didn't match the actual device pixel space.

How to fix this? Well, just as we have a device offset so that we can
relocate drawing inside a window, I've added a device scale factor so
that the user-visible device coordinate space needn't match the actual
device coordinate space. I think I got all of the tricks covered to make
this fiction invisible.

With this, the pure image based PostScript backend was suddenly a lot
happier; output resoulution matched that specified by the application.

Next, I adapted the meta-surface PostScript backend to scale the device
coordinate space appropriately and it too is far happier, with pages
rendered by the image fallbacks at the specified resolution.

With cworth's able review, I've actually committed these changes to CVS
for 1.0 so that we can have a fully armed and operational PostScript
backend. The only thing missing from it is the ability to collage the
output from bits of vector PostScript mixed with cairo-drawn images as
needed. That will have to wait until after 1.0 as it's "hard".

So, it turns out that we get the nice PS backend with the ability to
fully support cairo output. Seems like a good result to me.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050824/b2f906cd/attachment-0001.pgp

More information about the cairo mailing list