From 5099d00eb39c4b71c806dafd50d8e4f76eeb4875 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Thu, 23 Nov 2017 12:00:48 +0100 Subject: [PATCH] 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 --- repos/ports/src/app/vbox_pointer/policy.cc | 15 +++----------- .../ports/src/virtualbox5/frontend/console.h | 20 ++++++++++++++++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/repos/ports/src/app/vbox_pointer/policy.cc b/repos/ports/src/app/vbox_pointer/policy.cc index c3dad33382..ae46bd8ded 100644 --- a/repos/ports/src/app/vbox_pointer/policy.cc +++ b/repos/ports/src/app/vbox_pointer/policy.cc @@ -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); diff --git a/repos/ports/src/virtualbox5/frontend/console.h b/repos/ports/src/virtualbox5/frontend/console.h index a2234b0e82..9d1be85f57 100644 --- a/repos/ports/src/virtualbox5/frontend/console.h +++ b/repos/ports/src/virtualbox5/frontend/console.h @@ -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) {