[cairo] Problem in cairo + xcb where alpha blending is cumulative (becoming more opaque with each render)

Uli Schlachter psychon at znc.in
Thu Sep 27 07:56:01 UTC 2018


Hi,

On 26.09.2018 07:51, Ryan Flannery wrote:
> The raw transparency piece works fine and is
> easy in cairo + xcb,
sorry to tell you this, but the problem is in the raw transparency part.
You only *think* that you have transparency. Also, "is easy" is the
total opposite of the truth. Again, sorry.

When a new window is mapped, its content is undefined. In practice this
means that the window contains whatever was visible at this position
before. Thus, you think you have transparency when you draw ontop of
this. However, this is wrong.

Try apply the attached patch move.patch. What this patch does is to wait
for the window to become visible and then it moves the window. You will
notice that together with the window, its content is moved. Thus, making
it obvious that your transparency does not work.

The black background that you see is the working case *if your window
had an alpha channel*. Because it does not have an alpha channel, you
only see black.

To create a transparent window in X11, first of all, the user has to be
using a compositing manager (compiz, compton, xcompmgr, ...). Without
this, there is no real transparency. The _NET_WM_CMs selection can be
used to figure out if a compositing manager is running.

Next, you need to create a window with a 32bit visual (and also tell
cairo that your window is using this visual). For this part, I refer you to:

https://stackoverflow.com/questions/3645632/how-to-create-a-window-with-a-bit-depth-of-32

The attached patch fix.patch gives me a window with either a black
background (if no compositing manager is running) or a transparent black
background (if a compositing manager is running; I used compton).

Cheers,
Uli
-- 
Sent from my Game Boy.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: move.patch
Type: text/x-diff
Size: 3107 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20180927/e1afadc6/attachment-0002.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix.patch
Type: text/x-diff
Size: 3107 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20180927/e1afadc6/attachment-0003.patch>


More information about the cairo mailing list