24#include <l4/cxx/minmax>
26namespace L4Re {
namespace Video {
48 : _bits(bits), _shift(shift) {}
54 unsigned char size()
const {
return _bits; }
60 unsigned char shift()
const {
return _shift; }
67 {
return _shift == o._shift && _bits == o._bits; }
74 int get(
unsigned long v)
const
76 return ((v >> _shift) & ~(~0UL << _bits)) << (16UL - _bits);
84 long unsigned set(
int v)
const
85 {
return (
static_cast<unsigned long>(v) >> (16UL - _bits)) << _shift; }
91 template<
typename OUT >
94 s.printf(
"%d(%d)",
static_cast<int>(size()),
static_cast<int>(shift()));
96} __attribute__((packed));
144 unsigned char top_bit = cxx::max<unsigned char>(_r.
size() + _r.
shift(),
146 top_bit = cxx::max<unsigned char>(top_bit, _b.
size() + _b.
shift());
147 top_bit = cxx::max<unsigned char>(top_bit, _a.
size() + _a.
shift());
149 unsigned char bits = _bpp * 8;
223 Pixel_info(
unsigned char bpp,
char r,
char rs,
char g,
char gs,
224 char b,
char bs,
char a = 0,
char as = 0)
225 : _r(r, rs), _g(g, gs), _b(b, bs), _a(a, as), _bpp(bpp)
234 template<
typename VBI>
236 : _r(vbi->red_mask_size, vbi->red_field_position),
237 _g(vbi->green_mask_size, vbi->green_field_position),
238 _b(vbi->blue_mask_size, vbi->blue_field_position),
239 _bpp((vbi->bits_per_pixel + 7) / 8)
249 return _r == o._r && _g == o._g && _b == o._b && _a == o._a && _bpp == o._bpp;
256 template<
typename OUT >
259 s.printf(
"RGBA(%d):%d(%d):%d(%d):%d(%d):%d(%d)",
260 static_cast<int>(bytes_per_pixel()),
261 static_cast<int>(r().size()),
static_cast<int>(r().shift()),
262 static_cast<int>(g().size()),
static_cast<int>(g().shift()),
263 static_cast<int>(b().size()),
static_cast<int>(b().shift()),
264 static_cast<int>(a().size()),
static_cast<int>(a().shift()));
void dump(OUT &s) const
Dump information on the view information to a stream.
long unsigned set(int v) const
Transform 16bit normalized value to the component in the color space.
unsigned char size() const
Return the number of bits used by the component.
Color_component()
Constructor.
int get(unsigned long v) const
Get component from value (normalized to 16bits).
Color_component(unsigned char bits, unsigned char shift)
Constructor.
unsigned char shift() const
Return the position of the component in the pixel.
Color_component const & g() const
Return the green color compoment of the pixel.
Color_component const & b() const
Return the blue color compoment of the pixel.
Pixel_info(VBI const *vbi)
Convenience constructor.
Pixel_info(unsigned char bpp, char r, char rs, char g, char gs, char b, char bs, char a=0, char as=0)
Constructor.
Color_component const & a() const
Return the alpha color compoment of the pixel.
void a(Color_component const &c)
Set the alpha color component of the pixel.
void g(Color_component const &c)
Set the green color component of the pixel.
bool has_alpha() const
Return whether the pixel has an alpha channel.
Color_component const & r() const
Return the red color compoment of the pixel.
void bytes_per_pixel(unsigned char bpp)
Set the size of the pixel in bytes.
void r(Color_component const &c)
Set the red color component of the pixel.
void b(Color_component const &c)
Set the blue color component of the pixel.
void dump(OUT &s) const
Dump information on the pixel to a stream.
unsigned char bits_per_pixel() const
Number of bits of the pixel.
unsigned char bytes_per_pixel() const
Query size of pixel in bytes.
Color_component const padding() const
Compute the padding pseudo component.
L4 compiler related defines.
#define L4_EXPORT
Attribute to mark functions, variables, and data types as being exported from a library.