[cairo] Initial tests of cairo's PostScript backend with firefox
Carl Worth
cworth at cworth.org
Tue Apr 11 17:19:23 PDT 2006
On Thu, 06 Apr 2006 15:36:59 -0700, Carl Worth wrote:
>
> One way to help is for people to test things. The kinds of things I'd
> like as feedback from testers are, in order of severity:
>
> 1. Is the output ever "wrong", (graphics don't render properly, file
> fails to be read by an interesting interpreter, etc.)
>
> 2. Is the output using image fallbacks in a case where you think it
> shouldn't, (that is, your drawing doesn't have any fancy
> translucence or something else that PostScript can't support
> natively). In particular, I want to know if cairo is now using
> fallbacks for something that was handled natively by the cairo 1.0
> series.
Previously I had only been using cairo's test suite itself for testing
the recent improvements to the PostScript backend. Now, I've started
testing a slightly more interesting use case, which is firefox.
To do this, I've managed to build a trunk version of firefox[1] and
get some cairo-generated PostScript from it.
My belief is that most of what firefox would want to print, (ignoring
SVG content, and plugins, etc.), should be quire reasonable to support
as native PostScript or PDF output from cairo. So I'd like to
establish firefox as a sort of functional baseline for what kinds of
things we should support well in the upcoming 1.2 release.
By default, firefox builds against its own private copy of cairo. This
copy is synched periodically with upstream cairo, but as I write this
does not have the most recent modifications we've been making to the
PostScript backend. Mozilla's cairo also has a few patches that have
not yet been merged upstream.
Fortunately, Vladimir has been maintaining Mozilla's cairo in his
personal git repository, and git makes it really easy to merge these
various branches together to try things out.
So I merged mozilla's cairo with the central "master" cairo branch and
pushed that out to my personal tree as a "mozilla-merged" branch. I
also pushed out a "mozilla-merged-ps-type3" branch that merges the
mozilla stuff with keithp's recent ps-type3 branch [2].
After that, I fired up all three versions of firefox, (its head
version with its copy of cairo, and then two --enable-system-cairo
versions with the mozilla-merged and mozilla-merged-ps-type3).
This build of firefox calls itself "minefield" and starts out with an
initial page of:
http://www.mozilla.org/projects/minefield/
That seemed as useful a page as any for a first test, so I did
File->Print, selected "print to file" and managed to get 3 different
PostScript files as a result with the following sizes:
196122 minefield-mozilla.ps
1607847 minefield-mozilla-merged.ps
310802 minefield-mozilla-merged-ps-type3.ps
The files are here for your viewing pleasure:
http://cairographics.org/~cworth/images/minefield-mozilla.ps
http://cairographics.org/~cworth/images/minefield-mozilla-merged.ps
http://cairographics.org/~cworth/images/minefield-mozilla-merged-ps-type3.ps
If you look closely at the content of the files, you'll find that (as
expected) the mozilla version is doing full image fallbacks for both
pages of the output.
For the mozilla-merged version, the first page is still rendered as an
image, (triggered by a transparent PNG---but I consider this a bug to
be fixed before 1.2). The second page is all native PostScript
vectors, but the file size is huge because every character in the
output emits its path data once again.
The merged-ps-type3 version still has the same bug (as expected)
causing the first page to be treated as an image fallback. Here the
file size has gotten much better since the path data for each
character is output only once in the file.
As Keith recently mentioned the output of each character is an
independent show command along the lines of:
603 789 moveto <00> show
so that will be tightened up a bit as the code is fixed to emit a
single show command for many characters.
But getting significant file size savings beyond that will require
doing something other than type3 fonts to avoid having to embed the
entire path data for every character into the file, (though obviously,
it's sometimes a requirement to embed all this data into the output
file).
Anyway, as to the requirements I proposed above for testing:
1. Robustness.
From a glance, the output actually looks pretty good in all three
cases. For comparison, here is the result from printing the same
page as a PostScript file from firefox 1.5.0.1:
193814 minefield-firefox-1.5.ps
http://cairographics.org/~cworth/images/minefield-firefox-1.5.ps
The obvious differences are that when the cairo-based versions are
doing image output they are doing it at a much lower resolution
than the released firefox version. That may be just a missing or
incorrect call to _cairo_ps_surface_set_dpi in the mozilla source.
Notably, the cairo output does handle the transparency in the
minefield-icon.png, (where the firefox 1.5 print has a big black
square around it). So that will be an improvement eventually, (when
the image-fallback region is restricted to just this image and not
the whole page).
Finally, there are some layout differences, (the cairo-based
versions span nearly two pages). This may just be differences in
the code or configuration of the different versions of mozilla
here. At any rate, the layout looks "correct" based on the font
sizes, so I don't think there's any cairo bug here.
2. Granularity of image fallbacks.
I had been hoping that the dumb, page-level triggering of image
fallbacks might be sufficient for printing web pages. But obviously,
it's unacceptable for one tiny PNG icon with some transparency in
it to cause an entire page to be emitted as an image rather than as
native PostScript. So we'll definitely have to do finer-grained
regions for fallbacks before 1.2 is done.
This is what I want to focus on for the next couple of weeks, (as
well as making PDF as good or better than this state of the PS
backend).
As anyone wants to jump in and help, that would be much appreciated.
-Carl
[1] Complete build instructions for doing this are at:
http://developer.mozilla.org/en/docs/Build_Documentation
For less complete instructions, first establish a ~/.mzconfig file
that looks something like mine (optionally enabling
--enable-system-cairo as appropriate):
. $topsrcdir/browser/config/mozconfig
ac_add_options --enable-default-toolkit=cairo-gtk2
mk_add_options MOZ_CO_PROJECT=browser
ac_add_options --enable-application=browser
ac_add_options --disable-tests
ac_add_options --enable-svg
ac_add_options --enable-canvas
# To test with an installed version of cairo rather than the copy of
# cairo within mozilla's source tree, enable the following option:
#ac_add_options --enable-system-cairo
ac_add_options --enable-optimize="-O -g"
ac_add_options --disable-debug
ac_add_options --enable-pango
Then, follow steps something like the following (warning, I haven't
re-tested these, so I might have a mistake here):
cvs -d :pserver:anonymous at cvs-mirror.mozilla.org:/cvsroot login
# type the password anonymous
cvs -d :pserver:anonymous at cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk
cd mozilla
make -f client.mk checkout MOZ_CO_PROJECT=browser
./configure
make
Then to run the new firefox you can do:
./dist/bin/firefox
But that will complain at you if you have another instance of cairo
running. There's supposedly an environment variable (MOZ_NO_REMOTE=1 ?)
to disable that, but that's not working for me now. So what I do is
first create a separate profile, ("testing" say), with:
./dist/bin/firefox -P
and then use that with:
./dist/bin/firefox -P testing
[2] If you want to get at the original mozilla branch it is at:
git://git.cairographics.org/~vladimir/cairo mozilla-tree-cairo
While the two branches I merged are at:
git://git.cairographics.org/~cworth/cairo mozilla-merged
and:
git://git.cairographics.org/~cworth/cairo mozilla-merged-ps-type3
To work with any of these branches, you should start with a basic
clone of the central cairo tree[3] and from within it just "git fetch"
one of the above branches and then "git checkout" the branch.
For example, if you want to play with the latest-and-greatest stuff
(as of this email) you would do:
git fetch git://git.cairographics.org/~cworth/cairo mozilla-merged-ps-type3
git checkout mozilla-merged-ps-type3
[3] If you don't have a clone of the cairo source yet, you can get it
with:
git clone git://git.cairographics.org/git/cairo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060411/f5d4a6c8/attachment.pgp
More information about the cairo
mailing list