[cairo] Blend modes take 3
otte at gnome.org
Thu Oct 9 09:39:22 PDT 2008
Here's an update after yesterday's comments:
I've investigated the relevant specifications that support blend modes:
- ISO32000 (PDF standard based on 1.7)
People I've asked agree that this should be the definitive reference
for how blend modes should work in Cairo.
- Adobe PDF 1.7 specification
This one is identical to the ISO spec (unless I've missed something).
- SVG 1.2 draft specification
The SVG blend modes are based on reverse-engineering the PDF ones,
before they were published. Slight differences exist. But after asking
the SVG working group, they claimed that the SVG spec should be
adapted to match PDF. See
http://www.w3.org/Graphics/SVG/WG/track/issues/2095 for example.
THere's also discrepancies in corner cases for color-dodge and
I've also looked at applications and libraries to figure out how they
implement blend modes. I haven't tested their adherance to the specs
when not having source code, but compared their output to apps where I
do have source code available:
- Adobe Reader: Matches the PDF spec
- Adobe Photoshop CS 2: Matches the PDF spec
- Adobe Flash: Matches PDF and SVG specs (omits non-matching blend modes)
- Apple Quartz 2D: Matches the PDF spec (tested using Preview.app and a PDF)
- Trolltech Qt: (Almost) matches the SVG spec
- GiMP/GEGL: Matches the SVG spec
- Poppler's Splash backend: Matches the PDF spec (at least tries)
- My current patch: Matches the SVG spec
Looking at the above data and at the opinions of the people I've
talked to, the obviously best idea is to make Cairo match the PDF
specification, which is what I will be doing next.
I've already added the patch from Adrian that implements blend modes
for the PDF backend, and I'm running modified versions of Poppler,
librsvg and Swfdec that make use of the blend modes (and for testing).
What is still missing is the blend mode patch for the Quartz backend.
This should be relatively simple from looking at the code if one
changes calls to "CGContextSetCompositeOperation (surface->cgContext,
_cairo_quartz_cairo_operator_to_quartz (op));" with a "status =
_cairo_quartz_set_operator (surface->cgContext, op)" which would allow
returning unsupported for the Flash-only operators. However, I don't
run OS X, so I can't make this work. I'd love to get the output of the
extended-blend test from that though, so I can be sure we do the right
thing on Quartz.
More information about the cairo