genode/repos/os/include/os/pixel_rgb888.h
Norman Feske ef741ef80d Change pixel format to 32 bits per pixel
Until now, Genode's framebuffer session interface was based on the
RGB565 pixel format. This patch changes the pixel format to 32-bit
XRGB where the X part is ignored. It adapts all graphical applications
and device drivers accordingly.

The patch also adjusts the users of the drivers_interactive packages,
assigning 64 MiB RAM and 1500 caps to the drivers subsystem, which is
sufficient for covering high resolutions at 32 bits per pixel and to
accommodate multi-component USB HID input stacks.

Fixes #3784
2020-06-29 14:22:29 +02:00

55 lines
1.3 KiB
C++

/*
* \brief Template specializations for the RGB888 pixel format
* \author Norman Feske
* \date 2014-08-14
*/
/*
* Copyright (C) 2014-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _INCLUDE__OS__PIXEL_RGB888_H_
#define _INCLUDE__OS__PIXEL_RGB888_H_
#include <os/pixel_rgba.h>
namespace Genode {
typedef Pixel_rgba<uint32_t, Surface_base::RGB888,
0xff0000, 16, 0xff00, 8, 0xff, 0, 0, 0>
Pixel_rgb888;
template <>
inline Pixel_rgb888 Pixel_rgb888::avr(Pixel_rgb888 p1, Pixel_rgb888 p2)
{
Pixel_rgb888 res;
res.pixel = (((p1.pixel&0xfe00fe00)>>1) + ((p2.pixel&0xfe00fe00)>>1))
| (((p1.pixel&0x00fe00fe)>>1) + ((p2.pixel&0x00fe00fe)>>1));
return res;
}
template <>
inline Pixel_rgb888 Pixel_rgb888::blend(Pixel_rgb888 src, int alpha)
{
Pixel_rgb888 res;
res.pixel = (alpha * ((src.pixel & 0xff00) >> 8) & 0xff00)
| (((alpha * (src.pixel & 0xff00ff)) >> 8) & 0xff00ff);
return res;
}
template <>
inline Pixel_rgb888 Pixel_rgb888::mix(Pixel_rgb888 p1, Pixel_rgb888 p2, int alpha)
{
Pixel_rgb888 res;
res.pixel = blend(p1, 256 - alpha).pixel + blend(p2, alpha).pixel;
return res;
}
}
#endif /* _INCLUDE__OS__PIXEL_RGB888_H_ */