Gamma correct rendering with Wayland and Weston

Bill Spitzak spitzak at
Fri Sep 28 13:51:41 PDT 2012

Actual rendering of window contents is not done by Wayland so it should 
not effect this. However wayland and the shells do some compositing, and 
gamma changes how any partially-transparent pixels work. In current 
shells these are:

1. "shadows", which are typically drawn by the client as 
partially-transparent black and composited over the contents of lower 

2. "semi-transparent" objects, such as some of the drag icons. Drawn by 
the clients as pre-multiplied srgb.

3. The anti-aliased edges of any non-rectangular opaque objects, such as 
any windows that are not rectangular, the cursor, drag icons. Depending 
on the application these may be srgb or linear, though the difference is 
hard to see.

Wayland also does scaling and rotations but the difference between 
linear and srgb is much smaller for these. I think the real solution for 
this is to allow clients to know the actual transform of their surfaces 
to the screen and be allowed to draw the transformed image, since this 
will avoid resampling and filtering, as well as letting the clients 
choose the color space.

I suspect that if there are two windows and one is "linear" and another 
is "srgb", that it will be impossible to make the "shadows" of these two 
windows look identical, even if the shadows are drawn in different 
colors and opacity. It may work for black, but not for any color 
shadows, and it certainly will not work for semi-transparent objects.

Therefore I feel that wayland shells should use the same compositing 
rules for all windows, so it is possible for them to all match.

The client is free to use linear compositing into a window but this will 
not change how wayland composites that window with otehrs. When drawing 
the "shadow" it just has to draw whatever will produce the correct srgb 
values in the buffer.

In the future wayland may do linear compositing. But this will change 
for all windows at once. The "appearance library" that should be used to 
draw all the widgets and shadows will be aware of this and alter how it 
draws them.

John Kåre Alsaker wrote:
> Currently most applications are blissfully unaware of the concept of
> gamma which affects pretty much all rendering operations.

More information about the wayland-devel mailing list