[cairo] Supporting mixed image/native paginated surface output

Keith Packard keithp at keithp.com
Fri Jan 6 11:21:25 PST 2006


One of the goals of the PS and PDF surfaces is to mix 'native' and image
output in the same page. 

At present, the PS implementation has a 'big switch' which turns an
entire page into a single image if anything on the page cannot be
supported natively in postscript. In practice, this means that many (if
not all) postscript pages turn out as giant images, turning postscript
into a simple image encapsulation mechanism.

I think we've got a plan that will generate more native graphics. It's
not perfect, but we can work towards that goal in the future.

Ok, the basic plan is to imagine our output as two layers -- an image
layer underlying a native layer. Objects which are not natively
supported in the backend will appear only in the image layer. Objects
which can be drawn natively may be placed in either layer. They're
placed in the image layer when some image object overlays them, but
overwise they're left in the native layer even if they overlay an image
object. This should give correct results in all cases.

The first part of the implementation is to classify each operation as
image vs native. This is done by replaying the metasurface against a
backend-specific analysis surface which returns whether an operation is
supported or not. The replay code will mark objects in the meta surface
with the results of this test.

The bounds of each object are also computed, clipped to the active clip
region and saved with each object. 

Now, the objects in the metasurface are examined starting with the last
object and working towards the first. A region representing the area of
the page covered by image objects is kept, and starts empty.

The bounds of the object are retreived from the classification stage.

If the object was marked by the analysis phase as an image object, its
bounding box is union'ed into the image region. 

Otherwise, if the object is native, the bounding box is tested against
the image region. If it has a non empty intersection with the image
region, the object is remarked as an image object and its bounding box
is union'ed into the image region.

At this point, all metasurface objects have been marked as to whether
they must be drawn to an intermediate image surface or not.

If the resulting image region is non-empty, an intermediate image
surface of suitable size is created. The metasurface is replayed and all
objects which must be drawn to the image surface are painted to the
intermediate image surface. Afterwards, the image is painted to the real
output surface with normal backend functions.

Now the metasurface is replayed again and all objects marked as native
are drawn directly to the real output surface.

The resulting composite result should accurately reflect the desired
output.

-keith
 
-------------- 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/20060106/7035682d/attachment.pgp


More information about the cairo mailing list