vbox_pointer: use RGBA encoding in shape report

RGBA is more likely to be supported by new clients than VirtualBox's BGRA encoding.

Issue #2585
This commit is contained in:
Christian Prochaska 2017-11-23 12:00:48 +01:00 committed by Christian Helmuth
parent f710e10206
commit 5099d00eb3
2 changed files with 20 additions and 15 deletions

View File

@ -95,19 +95,10 @@ class Vbox_pointer::Policy_entry : public Vbox_pointer::Policy,
for (unsigned int y = 0; y < _shape_size.h(); y++) {
/* convert the shape data from BGRA encoding to RGBA encoding */
unsigned char *shape = shape_report->shape;
unsigned char *bgra_line = &shape[y * _shape_size.w() * 4];
unsigned char rgba_line[_shape_size.w() * 4];
for (unsigned int i = 0; i < _shape_size.w() * 4; i += 4) {
rgba_line[i + 0] = bgra_line[i + 2];
rgba_line[i + 1] = bgra_line[i + 1];
rgba_line[i + 2] = bgra_line[i + 0];
rgba_line[i + 3] = bgra_line[i + 3];
}
/* import the RGBA-encoded line into the texture */
texture.rgba(rgba_line, _shape_size.w(), y);
unsigned char *shape = shape_report->shape;
unsigned char *line = &shape[y * _shape_size.w() * 4];
texture.rgba(line, _shape_size.w(), y);
}
_updater.update_pointer(*this);

View File

@ -210,9 +210,23 @@ class GenodeConsole : public Console {
return;
}
Genode::memcpy(_shape_report->shape,
shape,
shape_size);
/* convert the shape data from BGRA encoding to RGBA encoding */
unsigned char const *bgra_shape = shape;
unsigned char *rgba_shape = _shape_report->shape;
for (unsigned int y = 0; y < _shape_report->height; y++) {
unsigned char const *bgra_line = &bgra_shape[y * _shape_report->width * 4];
unsigned char *rgba_line = &rgba_shape[y * _shape_report->width * 4];
for (unsigned int i = 0; i < _shape_report->width * 4; i += 4) {
rgba_line[i + 0] = bgra_line[i + 2];
rgba_line[i + 1] = bgra_line[i + 1];
rgba_line[i + 2] = bgra_line[i + 0];
rgba_line[i + 3] = bgra_line[i + 3];
}
}
if (fVisible && !fAlpha) {