Correctly populate max color values in server screen format

Authored by aacid on Jan 5 2020, 6:10 PM.

Description

Correctly populate max color values in server screen format

Summary:
Compute max color values from color masks, instead of relying on unreliable bits_per_rgb_value provided by xcb_visualtype_t.

In some cases (e.g. nvidia?) bits_per_rgb_value contains wrong value. This results in wrong max color values, and causes weird color translation inside libvncserver. Clients will see a screen which is sorta recognizable but in a complete off-color, making krfb unusable.

This is probably a bug in drivers, but x11vnc does not use this value[1], so I guess it's fair to ignore it in krfb too.

[1]: https://github.com/LibVNC/x11vnc/blob/master/src/screen.c#L3442

Reviewers: alexeymin, aacid, KDE Applications

Differential Revision: https://phabricator.kde.org/D25876

Details