mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 15:56:41 +00:00
parent
dc90740549
commit
85a1f91f59
@ -47,30 +47,38 @@ struct Framebuffer::Mode
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int _width, _height;
|
int _width = 0, _height = 0;
|
||||||
Format _format;
|
|
||||||
|
Format _format = INVALID;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helpers for sanitized access. The sanitizing is needed whenever
|
||||||
|
* a 'Mode' object is transferred via RPC from an untrusted client.
|
||||||
|
*/
|
||||||
|
static Format _sanitized(Format f) { return f == RGB565 ? RGB565 : INVALID; }
|
||||||
|
static int _sanitized(int v) { return v >= 0 ? v : 0; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Mode() : _width(0), _height(0), _format(INVALID) { }
|
Mode() { }
|
||||||
|
|
||||||
Mode(int width, int height, Format format)
|
Mode(int width, int height, Format format)
|
||||||
: _width(width), _height(height), _format(format) { }
|
: _width(width), _height(height), _format(format) { }
|
||||||
|
|
||||||
int width() const { return _width; }
|
int width() const { return _sanitized(_width); }
|
||||||
int height() const { return _height; }
|
int height() const { return _sanitized(_height); }
|
||||||
Format format() const { return _format; }
|
Format format() const { return _sanitized(_format); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return number of bytes per pixel
|
* Return number of bytes per pixel
|
||||||
*/
|
*/
|
||||||
Genode::size_t bytes_per_pixel() const {
|
Genode::size_t bytes_per_pixel() const {
|
||||||
return bytes_per_pixel(_format); }
|
return bytes_per_pixel(format()); }
|
||||||
|
|
||||||
void print(Genode::Output &out) const
|
void print(Genode::Output &out) const
|
||||||
{
|
{
|
||||||
Genode::print(out, _width, "x", _height, "@");
|
Genode::print(out, width(), "x", height(), "@");
|
||||||
switch (_format) {
|
switch (format()) {
|
||||||
case RGB565: Genode::print(out, "RGB565"); break;
|
case RGB565: Genode::print(out, "RGB565"); break;
|
||||||
default: Genode::print(out, "INVALID"); break;
|
default: Genode::print(out, "INVALID"); break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user