PS/PDF API Change Proposal: (Re: [cairo] Semantics of transparent objects)

Bill Spitzak spitzak at d2.com
Fri Jan 20 11:29:34 PST 2006


 >>In fact, which variant is required depends solely on what kind of
 >>surface the original code was written for. In most cases, it will be a
 >>COLOR surface (most X surfaces, all Windows surfaces), and so a COLOR
 >>printer surface will produce matching output. In some cases, it willbe
 >>a COLOR_ALPHA surface (ARGB X surfaces, PNG files), where COLOR_ALPHA
 >>will produce matching output.

Okay I think I missed something here. It sounds like the original 
behavior of Cairo is fine, where CLEAR draws black.

If you make a COLOR window, and draw CLEAR into it, do you get black? If 
you make a COLOR_ALPHA and draw CLEAR into it, and then copy it to a 
COLOR surface, do you get black? It sounds like this is true. In that 
case I see no problem with having the PostScript surface be defined as 
being a COLOR surface and producing black, just like it does not. It 
really does match the other surfaces!

My proposal really amounts to changing the behavior of *all* COLOR 
surfaces so that CLEAR draws white, and so that copying a COLOR_ALPHA 
surface into the COLOR one puts c+1-a into each pixel. The reason for 
this is apparently that is what is expected of PostScript output, so it 
is better to change other surfaces where this does not matter to match 
PostScript.

This also means that OVER and COPY onto a PostScript surface do similar 
things, which may avoid a lot of confusion.

Defaulting surfaces to white may seem mathematically wrong, but in some 
ways it is better (the default color is all 1's, rather than three 0's 
and a one).

Also it makes a Cairo program that messes up and displays nothing 
produce a white window, which may look nicer next to other modern software.

I don't really like the idea of having to specify whether alpha is used 
when creating the surface. The backend authors should not have to 
implement both, and programmers should not have to keep looking up which 
one is the "fast" one for each backend. Backends that really can 
implement both can do tricks like detecting if the first drawing call 
fills the entire area with opaque paint and using that to indicate that 
alpha is not needed.



More information about the cairo mailing list