os: Pixel_rgba::transfer interface

The new 'transfer' function interface defines how pixel/alpha values
sampled from texture are applied to a destination pixel, similar to the
role of a fragment shader in GPU-based rendering. The transfer function
can be customized by defining custom pixel types, which may be (but
don't need to be) derived from 'Pixel_rgba'.

Issue #3221
This commit is contained in:
Norman Feske 2019-03-09 17:27:24 +01:00 committed by Christian Helmuth
parent b00e1f4e4b
commit ebd9f36b0d

View File

@ -116,6 +116,23 @@ class Genode::Pixel_rgba
Pixel_rgba p3, Pixel_rgba p4) {
return avr(avr(p1, p2), avr(p3, p4)); }
/**
* Copy pixel with alpha
*
* \param src source color value (e.g., obtained from a texture)
* \param src_a alpha value corresponding to the 'src' pixel
* \param alpha alpha value
* \param dst destination pixel
*/
template <typename TPT, typename PT>
static void transfer(TPT const &src, int src_a, int alpha, PT &dst)
{
if (src_a) {
int register a = (src_a * alpha)>>8;
if (a) dst = PT::mix(dst, src, a);
}
}
/**
* Return alpha value of pixel
*/