The cairo_output_stream_t object already had an internal status value,
but it was annoyingly returning status values from various functions.
It also was missing proper shutdown-on-error as well as nil-create
semantics.
This fixes those shortcomings and adjusts all callers for the new
semantics, (leading to simpler and more correct calling
code---particularly in the case of cairo-base85-stream.c).
Now _cairo_output_stream_create accepts a new close callback, (which
the base85 stream uses to write its trailer). This eliminates the
former kludge used to fclose the stdio output streams, and required a
bit of touchup to the pdf, ps, and svg-surface usage of streams.
This switches the implementation of _cairo_lzw_compress from using
cairo-hash.c to a custom implementation of the same algorithm that
takes advantage of the specific details of what is needed here.
This final version now has comparable performance to the libtiff code,
but should hopefully be easier to understand.
Add a bunch of comments explaining how the various pieces work.
This new implementation is an entirely original work directly from the
description of the LZWDecode filter in the PostScript Language
Reference, (and in spite of the bugs in the examples provided in that
reference).
This implementation uses the existing cairo-hash.c for the symbol
table. This implementation is somewhat easier to read than the libtiff
code, and avoids any code that may have an advertising clause
attached. This new implementation is the simplest thing I could
implement. It is not as efficient as the libtiff code, (though I did
expect better things from cairo-hash.c).
* src/Makefile.am:
Add cairo-lzw.c to sources
Remove erronous space at start of line
* src/cairo-lzw.c:
New file implementing _cairo_compress_lzw which does Lempel-Ziv & Welch
compression as used by postscript. Based on code from libtiff.
* src/cairo-output-stream.c:
Add _cairo_output_stream_write_base85_string which implements
an encoder for the ASCII85Decode postscript filter.
* src/cairoint.h:
Add _cairo_compress_lzw and _cairo_output_stream_write_base85_string.
* src/cairo-ps-surface.c:
Write Images LZW + Base85 encoded.
Change ps level to 2 (we only needed level 3 for FlateDecode).
Change DocumentData to Clean7Bit as we don't include binary data
anymore.
Surely, the ! instead of ~ here was just a typo. I'd feel better if I
had a failing test case for this though, (time to break out gcov
again).
Fixes bug #6185:
Strange pointer operations in fbCompositeTrans_0888xnx0888 (pixman/src/fbpict.c)
https://bugs.freedesktop.org/show_bug.cgi?id=6185
Bogus fix; misunderstood the relationship between the font bearings
and the computed device offsets. Real fix on my device offsets branch.
This reverts 49b4fe10d0 commit.
cairo-ft-font was being naughty and storing glyph bearings in the
surface device_[xy]_offset fields -- this had no effect previously,
because _cairo_surface_composite ignored those fields, but once it
starts handling device offsets itself, this causes ft text rendering
to break.