[cairo] Simplifying the operator set
Carl Worth
cworth at cworth.org
Thu Jan 6 22:45:58 PST 2005
The recent discussions of the rendering equation have prompted me to
re-examine the list of compositing operators in cairo.
I'd like to simplify the operator set a bit, so I'm proposing the
following changes (roughly sorted with most trivial changes last):
* Eliminate CLEAR.
This operator is a real oddball. It's the only one that does
not examine the source pattern. And its result is easily
emulated with SOURCE and a current alpha of 0.
* Eliminate ATOP, ATOP_REVERSE, and XOR.
These operators are called "less useful" in the original
Porter/Duff paper. I haven't seen any specific use for them,
and they are easily decomposed into the union of other
operators as described in the paper:
"A atop B is the union of A in B and B out A"
"A xor B is the union of A out B and B out A".
Plus the name of the XOR operator has led several users to
expect something entirely different, so eliminating that
confusion source can only help.
* Abbreviate less: SRC -> SOURCE, DST -> DEST
Cairo has an abbreviation-adverse naming style favoring
legibility over dubious benefits such as keystrokes or file
size [*]. "DESTINATION" might be pushing it though. We could
use other names, (input and output?), which would deviate a
bit further from RENDER, but not from Porter/Duff, (who only
use A and B in the paper).
* Rename all of the REVERSE operators. FOO_REVERSE -> DEST_FOO
These operators can be very useful, (it's fun to punch holes
in things with OUT_REVERSE). But I am often have to do a long
stop-and-think to figure them out. I think the mental
gymnastics have to do with mapping "src OUT_REVERSE dest" to
"dest OUT src". It seems a name of DEST_OUT will guide me more
naturally to the correct operation.
* Reorder the list to group SOURCE and DEST.
So, if we do all of those, we end up with the following list:
typedef enum cairo_operator {
CAIRO_OPERATOR_SOURCE
CAIRO_OPERATOR_OVER,
CAIRO_OPERATOR_IN,
CAIRO_OPERATOR_OUT,
CAIRO_OPERATOR_DEST,
CAIRO_OPERATOR_DEST_OVER,
CAIRO_OPERATOR_DEST_IN,
CAIRO_OPERATOR_DEST_OUT,
CAIRO_OPERATOR_ADD,
CAIRO_OPERATOR_SATURATE
} cairo_operator_t;
Maybe that helps a bit, (or maybe it just doesn't matter that much).
But feedback is welcome, as always.
-Carl
[*] We do have some well-known acronyms that I don't mind at all,
(rgb, pdf, ps, png).
I note that there are a few abbreviations that have slipped into
function names: "concat", "init", and "rel". These come from
PostScript naming conventions, (though "rel" is already less
abbreviated than PostScript's "r").
More information about the cairo
mailing list