Replace Framebuffer::info by Framebuffer::mode
As a preliminary step for working on issue #11, this patch revisits the 'Framebuffer::info' RPC call. Instead of using C-style out paramters, the new 'mode()' RPC call returns the mode information as an object of type 'Mode'. Consequently, mode-specific functions such as 'bytes_per_pixel' have been moved to the new 'Framebuffer::Mode' class.
This commit is contained in:
parent
07a9a8361e
commit
9e3ecade16
|
@ -234,16 +234,14 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
static Nitpicker::Connection nitpicker;
|
static Nitpicker::Connection nitpicker;
|
||||||
static Framebuffer::Session_client framebuffer(nitpicker.framebuffer_session());
|
static Framebuffer::Session_client framebuffer(nitpicker.framebuffer_session());
|
||||||
static int fb_width, fb_height;
|
|
||||||
static Framebuffer::Session::Mode fb_mode;
|
|
||||||
Nitpicker::View_capability view_cap = nitpicker.create_view();
|
Nitpicker::View_capability view_cap = nitpicker.create_view();
|
||||||
static Nitpicker::View_client view(view_cap);
|
static Nitpicker::View_client view(view_cap);
|
||||||
|
|
||||||
/* obtain screen size */
|
/* obtain screen size */
|
||||||
framebuffer.info(&fb_width, &fb_height, &fb_mode);
|
Framebuffer::Mode const mode = framebuffer.mode();
|
||||||
|
|
||||||
if (fb_mode != Framebuffer::Session::RGB565) {
|
if (mode.format() != Framebuffer::Mode::RGB565) {
|
||||||
printf("Error: Color mode %d not supported\n", (int)fb_mode);
|
printf("Error: Color mode %d not supported\n", (int)mode.format());
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,13 +249,13 @@ int main(int argc, char **argv)
|
||||||
uint16_t *fb = env()->rm_session()->attach(framebuffer.dataspace());
|
uint16_t *fb = env()->rm_session()->attach(framebuffer.dataspace());
|
||||||
|
|
||||||
/* fill virtual framebuffer with decoded image data */
|
/* fill virtual framebuffer with decoded image data */
|
||||||
convert_png_to_rgb565(png_data, fb, fb_width, fb_height);
|
convert_png_to_rgb565(png_data, fb, mode.width(), mode.height());
|
||||||
|
|
||||||
/* display view behind all others */
|
/* display view behind all others */
|
||||||
nitpicker.background(view_cap);
|
nitpicker.background(view_cap);
|
||||||
view.viewport(0, 0, fb_width, fb_height, 0, 0, false);
|
view.viewport(0, 0, mode.width(), mode.height(), 0, 0, false);
|
||||||
view.stack(Nitpicker::View_capability(), false, false);
|
view.stack(Nitpicker::View_capability(), false, false);
|
||||||
framebuffer.refresh(0, 0, fb_width, fb_height);
|
framebuffer.refresh(0, 0, mode.width(), mode.height());
|
||||||
|
|
||||||
sleep_forever();
|
sleep_forever();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
static int _scr_w;
|
static int _scr_w;
|
||||||
static int _scr_h;
|
static int _scr_h;
|
||||||
static Framebuffer::Session::Mode _scr_mode;
|
static Framebuffer::Mode::Format _scr_format;
|
||||||
static Input::Event *_ev_buf;
|
static Input::Event *_ev_buf;
|
||||||
static char *_scr_adr;
|
static char *_scr_adr;
|
||||||
static char *_buf_adr;
|
static char *_buf_adr;
|
||||||
|
@ -221,7 +221,10 @@ Platform::Platform(unsigned vx, unsigned vy, unsigned vw, unsigned vh,
|
||||||
* propagated to different nitpicker instances.
|
* propagated to different nitpicker instances.
|
||||||
*/
|
*/
|
||||||
_nitpicker = new (env()->heap()) Nitpicker::Connection();
|
_nitpicker = new (env()->heap()) Nitpicker::Connection();
|
||||||
_nitpicker->framebuffer()->info(&_scr_w, &_scr_h, &_scr_mode);
|
Framebuffer::Mode const query_mode = _nitpicker->framebuffer()->mode();
|
||||||
|
_scr_w = query_mode.width();
|
||||||
|
_scr_h = query_mode.height();
|
||||||
|
_scr_format = query_mode.format();
|
||||||
destroy(env()->heap(), _nitpicker);
|
destroy(env()->heap(), _nitpicker);
|
||||||
|
|
||||||
if (_max_vw) _scr_w = min(_max_vw, _scr_w);
|
if (_max_vw) _scr_w = min(_max_vw, _scr_w);
|
||||||
|
@ -231,21 +234,21 @@ Platform::Platform(unsigned vx, unsigned vy, unsigned vw, unsigned vh,
|
||||||
* Allocate a nitpicker buffer double as high as the physical screen to
|
* Allocate a nitpicker buffer double as high as the physical screen to
|
||||||
* use the upper/lower halves for double-buffering.
|
* use the upper/lower halves for double-buffering.
|
||||||
*/
|
*/
|
||||||
_nitpicker = new (env()->heap()) Nitpicker::Connection(_scr_w, _scr_h*2, false, _scr_mode);
|
_nitpicker = new (env()->heap())
|
||||||
|
Nitpicker::Connection(_scr_w, _scr_h*2, false, _scr_format);
|
||||||
|
|
||||||
static Timer::Connection timer;
|
static Timer::Connection timer;
|
||||||
_timer = &timer;
|
_timer = &timer;
|
||||||
|
|
||||||
int dummy = 0;
|
Framebuffer::Mode const used_mode = _nitpicker->framebuffer()->mode();
|
||||||
_nitpicker->framebuffer()->info(&dummy, &dummy, &_scr_mode);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use the upper half the allocated nitpicker buffer for '_scr_adr'
|
* We use the upper half the allocated nitpicker buffer for '_scr_adr'
|
||||||
* and the lower half for '_buf_adr'.
|
* and the lower half for '_buf_adr'.
|
||||||
*/
|
*/
|
||||||
_scr_adr = env()->rm_session()->attach(_nitpicker->framebuffer()->dataspace());
|
_scr_adr = env()->rm_session()->attach(_nitpicker->framebuffer()->dataspace());
|
||||||
_buf_adr = (char *)_scr_adr + _scr_w*_scr_h*Framebuffer::Session::bytes_per_pixel(_scr_mode);
|
_buf_adr = (char *)_scr_adr + _scr_w*_scr_h*used_mode.bytes_per_pixel();
|
||||||
_ev_buf = env()->rm_session()->attach(_nitpicker->input()->dataspace());
|
_ev_buf = env()->rm_session()->attach(_nitpicker->input()->dataspace());
|
||||||
|
|
||||||
new (env()->heap()) Timer_thread();
|
new (env()->heap()) Timer_thread();
|
||||||
|
|
||||||
|
@ -290,7 +293,7 @@ void Platform::flip_buf_scr()
|
||||||
*/
|
*/
|
||||||
void Platform::copy_buf_to_scr(int x, int y, int w, int h)
|
void Platform::copy_buf_to_scr(int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
Genode::size_t bpp = Framebuffer::Session::bytes_per_pixel(_scr_mode);
|
Genode::size_t bpp = Framebuffer::Mode::bytes_per_pixel(_scr_format);
|
||||||
|
|
||||||
/* copy background buffer to foreground buffer */
|
/* copy background buffer to foreground buffer */
|
||||||
int len = w*bpp;
|
int len = w*bpp;
|
||||||
|
|
|
@ -198,11 +198,10 @@ namespace Framebuffer
|
||||||
|
|
||||||
Genode::Dataspace_capability dataspace() { return _window_content->fb_ds_cap(); }
|
Genode::Dataspace_capability dataspace() { return _window_content->fb_ds_cap(); }
|
||||||
|
|
||||||
void info(int *out_w, int *out_h, Mode *out_mode)
|
Mode mode()
|
||||||
{
|
{
|
||||||
*out_w = _window_content->fb_w();
|
return Mode(_window_content->fb_w(), _window_content->fb_h(),
|
||||||
*out_h = _window_content->fb_h();
|
Mode::RGB565);
|
||||||
*out_mode = RGB565;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh(int x, int y, int w, int h) {
|
void refresh(int x, int y, int w, int h) {
|
||||||
|
|
|
@ -784,14 +784,12 @@ namespace Terminal {
|
||||||
|
|
||||||
Genode::Attached_ram_dataspace _io_buffer;
|
Genode::Attached_ram_dataspace _io_buffer;
|
||||||
|
|
||||||
int _fb_width;
|
Framebuffer::Mode _fb_mode;
|
||||||
int _fb_height;
|
|
||||||
Genode::Dataspace_capability _fb_ds_cap;
|
Genode::Dataspace_capability _fb_ds_cap;
|
||||||
unsigned _char_width;
|
unsigned _char_width;
|
||||||
unsigned _char_height;
|
unsigned _char_height;
|
||||||
unsigned _columns;
|
unsigned _columns;
|
||||||
unsigned _lines;
|
unsigned _lines;
|
||||||
Framebuffer::Session::Mode _fb_mode;
|
|
||||||
void *_fb_addr;
|
void *_fb_addr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -810,10 +808,8 @@ namespace Terminal {
|
||||||
*/
|
*/
|
||||||
Genode::Dataspace_capability _init_fb()
|
Genode::Dataspace_capability _init_fb()
|
||||||
{
|
{
|
||||||
_framebuffer->info(&_fb_width, &_fb_height, &_fb_mode);
|
if (_fb_mode.format() != Framebuffer::Mode::RGB565) {
|
||||||
|
PERR("Color mode %d not supported", _fb_mode.format());
|
||||||
if (_fb_mode != Framebuffer::Session::RGB565) {
|
|
||||||
PERR("Color mode %d not supported", _fb_mode);
|
|
||||||
return Genode::Dataspace_capability();
|
return Genode::Dataspace_capability();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -830,6 +826,7 @@ namespace Terminal {
|
||||||
Genode::size_t io_buffer_size)
|
Genode::size_t io_buffer_size)
|
||||||
: _read_buffer(read_buffer), _framebuffer(framebuffer),
|
: _read_buffer(read_buffer), _framebuffer(framebuffer),
|
||||||
_io_buffer(Genode::env()->ram_session(), io_buffer_size),
|
_io_buffer(Genode::env()->ram_session(), io_buffer_size),
|
||||||
|
_fb_mode(_framebuffer->mode()),
|
||||||
_fb_ds_cap(_init_fb()),
|
_fb_ds_cap(_init_fb()),
|
||||||
|
|
||||||
/* take size of space character as character cell size */
|
/* take size of space character as character cell size */
|
||||||
|
@ -837,8 +834,8 @@ namespace Terminal {
|
||||||
_char_height(mono_font.str_h("m")),
|
_char_height(mono_font.str_h("m")),
|
||||||
|
|
||||||
/* compute number of characters fitting on the framebuffer */
|
/* compute number of characters fitting on the framebuffer */
|
||||||
_columns(_fb_width/_char_width),
|
_columns(_fb_mode.width()/_char_width),
|
||||||
_lines(_fb_height/_char_height),
|
_lines(_fb_mode.height()/_char_height),
|
||||||
|
|
||||||
_fb_addr(Genode::env()->rm_session()->attach(_fb_ds_cap)),
|
_fb_addr(Genode::env()->rm_session()->attach(_fb_ds_cap)),
|
||||||
_char_cell_array(_columns, _lines, Genode::env()->heap()),
|
_char_cell_array(_columns, _lines, Genode::env()->heap()),
|
||||||
|
@ -848,11 +845,11 @@ namespace Terminal {
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
printf("new terminal session:\n");
|
printf("new terminal session:\n");
|
||||||
printf(" framebuffer has %dx%d pixels\n", _fb_width, _fb_height);
|
printf(" framebuffer has %dx%d pixels\n", _fb_mode.width(), _fb_mode.height());
|
||||||
printf(" character size is %dx%d pixels\n", _char_width, _char_height);
|
printf(" character size is %dx%d pixels\n", _char_width, _char_height);
|
||||||
printf(" terminal size is %dx%d characters\n", _columns, _lines);
|
printf(" terminal size is %dx%d characters\n", _columns, _lines);
|
||||||
|
|
||||||
framebuffer->refresh(0, 0, _fb_width, _fb_height);
|
framebuffer->refresh(0, 0, _fb_mode.width(), _fb_mode.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush()
|
void flush()
|
||||||
|
@ -861,8 +858,8 @@ namespace Terminal {
|
||||||
|
|
||||||
convert_char_array_to_pixels<Pixel_rgb565>(&_char_cell_array,
|
convert_char_array_to_pixels<Pixel_rgb565>(&_char_cell_array,
|
||||||
(Pixel_rgb565 *)_fb_addr,
|
(Pixel_rgb565 *)_fb_addr,
|
||||||
_fb_width,
|
_fb_mode.width(),
|
||||||
_fb_height);
|
_fb_mode.height());
|
||||||
|
|
||||||
|
|
||||||
int first_dirty_line = 10000,
|
int first_dirty_line = 10000,
|
||||||
|
@ -880,7 +877,7 @@ namespace Terminal {
|
||||||
int num_dirty_lines = last_dirty_line - first_dirty_line + 1;
|
int num_dirty_lines = last_dirty_line - first_dirty_line + 1;
|
||||||
|
|
||||||
_framebuffer->refresh(0, first_dirty_line*_char_height,
|
_framebuffer->refresh(0, first_dirty_line*_char_height,
|
||||||
_fb_width, num_dirty_lines*_char_height);
|
_fb_mode.width(), num_dirty_lines*_char_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,20 +61,19 @@ class Genode_framebuffer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Framebuffer::Connection _framebuffer;
|
Framebuffer::Connection _framebuffer;
|
||||||
int _width, _height;
|
Framebuffer::Mode const _mode;
|
||||||
Framebuffer::Session::Mode _mode;
|
Genode::Dataspace_capability const _ds_cap;
|
||||||
Genode::Dataspace_capability _ds_cap;
|
void * const _local_addr;
|
||||||
void *_local_addr;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Genode_framebuffer()
|
Genode_framebuffer()
|
||||||
{
|
:
|
||||||
_framebuffer.info(&_width, &_height, &_mode);
|
_mode(_framebuffer.mode()),
|
||||||
_ds_cap = _framebuffer.dataspace();
|
_ds_cap(_framebuffer.dataspace()),
|
||||||
_local_addr = Genode::env()->rm_session()->attach(_ds_cap);
|
_local_addr(Genode::env()->rm_session()->attach(_ds_cap))
|
||||||
}
|
{ }
|
||||||
|
|
||||||
~Genode_framebuffer()
|
~Genode_framebuffer()
|
||||||
{
|
{
|
||||||
|
@ -85,11 +84,11 @@ class Genode_framebuffer
|
||||||
|
|
||||||
void flush()
|
void flush()
|
||||||
{
|
{
|
||||||
_framebuffer.refresh(0, 0, _width, _height);
|
_framebuffer.refresh(0, 0, _mode.width(), _mode.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
int width() const { return _width; }
|
int width() const { return _mode.width(); }
|
||||||
int height() const { return _height; }
|
int height() const { return _mode.height(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,7 @@ extern "C" {
|
||||||
#include "SDL_genode_fb_video.h"
|
#include "SDL_genode_fb_video.h"
|
||||||
|
|
||||||
static Framebuffer::Connection *framebuffer = 0;
|
static Framebuffer::Connection *framebuffer = 0;
|
||||||
static Framebuffer::Session::Mode scr_mode = Framebuffer::Session::INVALID;
|
static Framebuffer::Mode scr_mode;
|
||||||
static int width = 0;
|
|
||||||
static int height = 0;
|
|
||||||
static SDL_Rect *modes[2];
|
static SDL_Rect *modes[2];
|
||||||
static SDL_Rect df_mode;
|
static SDL_Rect df_mode;
|
||||||
|
|
||||||
|
@ -156,19 +154,19 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the framebuffer size and mode infos */
|
/* Get the framebuffer size and mode infos */
|
||||||
framebuffer->info(&width, &height, &scr_mode);
|
scr_mode = framebuffer->mode();
|
||||||
t->info.current_w = width;
|
t->info.current_w = scr_mode.width();
|
||||||
t->info.current_h = height;
|
t->info.current_h = scr_mode.height();
|
||||||
PDBG("Framebuffer has width=%d and height=%d",
|
PDBG("Framebuffer has width=%d and height=%d",
|
||||||
t->info.current_w, t->info.current_h);
|
t->info.current_w, t->info.current_h);
|
||||||
|
|
||||||
/* set mode specific values */
|
/* set mode specific values */
|
||||||
switch(scr_mode)
|
switch(scr_mode.format())
|
||||||
{
|
{
|
||||||
case Framebuffer::Session::RGB565:
|
case Framebuffer::Mode::RGB565:
|
||||||
PDBG("We use pixelformat rgb565.");
|
PDBG("We use pixelformat rgb565.");
|
||||||
vformat->BitsPerPixel = 16;
|
vformat->BitsPerPixel = 16;
|
||||||
vformat->BytesPerPixel = 2;
|
vformat->BytesPerPixel = scr_mode.bytes_per_pixel();
|
||||||
vformat->Rmask = 0x0000f800;
|
vformat->Rmask = 0x0000f800;
|
||||||
vformat->Gmask = 0x000007e0;
|
vformat->Gmask = 0x000007e0;
|
||||||
vformat->Bmask = 0x0000001f;
|
vformat->Bmask = 0x0000001f;
|
||||||
|
@ -179,8 +177,8 @@ extern "C" {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
modes[0] = &df_mode;
|
modes[0] = &df_mode;
|
||||||
df_mode.w = width;
|
df_mode.w = scr_mode.width();
|
||||||
df_mode.h = height;
|
df_mode.h = scr_mode.height();
|
||||||
modes[1] = 0;
|
modes[1] = 0;
|
||||||
|
|
||||||
/* Map the buffer */
|
/* Map the buffer */
|
||||||
|
|
|
@ -27,8 +27,8 @@ namespace Framebuffer {
|
||||||
Genode::Dataspace_capability dataspace() {
|
Genode::Dataspace_capability dataspace() {
|
||||||
return call<Rpc_dataspace>(); }
|
return call<Rpc_dataspace>(); }
|
||||||
|
|
||||||
void info(int *out_w, int *out_h, Mode *out_mode) {
|
Mode mode() {
|
||||||
call<Rpc_info>(out_w, out_h, out_mode); }
|
return call<Rpc_mode>(); }
|
||||||
|
|
||||||
void refresh(int x, int y, int w, int h) {
|
void refresh(int x, int y, int w, int h) {
|
||||||
call<Rpc_refresh>(x, y, w, h); }
|
call<Rpc_refresh>(x, y, w, h); }
|
||||||
|
|
|
@ -28,7 +28,8 @@ namespace Framebuffer {
|
||||||
/**
|
/**
|
||||||
* Create session and return typed session capability
|
* Create session and return typed session capability
|
||||||
*/
|
*/
|
||||||
Session_capability _connect(unsigned width, unsigned height, Mode mode)
|
Session_capability _connect(unsigned width, unsigned height,
|
||||||
|
Mode::Format format)
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
@ -43,8 +44,8 @@ namespace Framebuffer {
|
||||||
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_width", width);
|
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_width", width);
|
||||||
if (height)
|
if (height)
|
||||||
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_height", height);
|
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_height", height);
|
||||||
if (mode != Session::INVALID)
|
if (format != Mode::INVALID)
|
||||||
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_mode", mode);
|
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_format", format);
|
||||||
|
|
||||||
return session(argbuf);
|
return session(argbuf);
|
||||||
}
|
}
|
||||||
|
@ -62,11 +63,11 @@ namespace Framebuffer {
|
||||||
* session, you should validate the actual frame-buffer attributes
|
* session, you should validate the actual frame-buffer attributes
|
||||||
* by calling the 'info' function of the frame-buffer interface.
|
* by calling the 'info' function of the frame-buffer interface.
|
||||||
*/
|
*/
|
||||||
Connection(unsigned width = 0,
|
Connection(unsigned width = 0,
|
||||||
unsigned height = 0,
|
unsigned height = 0,
|
||||||
Mode mode = INVALID)
|
Mode::Format format = Mode::INVALID)
|
||||||
:
|
:
|
||||||
Genode::Connection<Session>(_connect(width, height, mode)),
|
Genode::Connection<Session>(_connect(width, height, format)),
|
||||||
Session_client(cap())
|
Session_client(cap())
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,15 +19,48 @@
|
||||||
|
|
||||||
namespace Framebuffer {
|
namespace Framebuffer {
|
||||||
|
|
||||||
|
struct Mode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pixel formats
|
||||||
|
*/
|
||||||
|
enum Format { INVALID, RGB565 };
|
||||||
|
|
||||||
|
static Genode::size_t bytes_per_pixel(Format format)
|
||||||
|
{
|
||||||
|
if (format == RGB565) return 2;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
int _width, _height;
|
||||||
|
Format _format;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Mode() : _width(0), _height(0), _format(INVALID) { }
|
||||||
|
|
||||||
|
Mode(int width, int height, Format format)
|
||||||
|
: _width(width), _height(height), _format(format) { }
|
||||||
|
|
||||||
|
int width() const { return _width; }
|
||||||
|
int height() const { return _height; }
|
||||||
|
Format format() const { return _format; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return number of bytes per pixel
|
||||||
|
*/
|
||||||
|
Genode::size_t bytes_per_pixel() const {
|
||||||
|
return bytes_per_pixel(_format); }
|
||||||
|
};
|
||||||
|
|
||||||
struct Session : Genode::Session
|
struct Session : Genode::Session
|
||||||
{
|
{
|
||||||
static const char *service_name() { return "Framebuffer"; }
|
static const char *service_name() { return "Framebuffer"; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Pixel formats
|
|
||||||
*/
|
|
||||||
enum Mode { INVALID, RGB565 };
|
|
||||||
|
|
||||||
virtual ~Session() { }
|
virtual ~Session() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,12 +70,8 @@ namespace Framebuffer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request current screen mode properties
|
* Request current screen mode properties
|
||||||
*
|
|
||||||
* \param out_w width of frame buffer
|
|
||||||
* \param out_h height of frame buffer
|
|
||||||
* \param out_mode pixel format
|
|
||||||
*/
|
*/
|
||||||
virtual void info(int *out_w, int *out_h, Mode *out_mode) = 0;
|
virtual Mode mode() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush specified pixel region
|
* Flush specified pixel region
|
||||||
|
@ -51,21 +80,16 @@ namespace Framebuffer {
|
||||||
*/
|
*/
|
||||||
virtual void refresh(int x, int y, int w, int h) = 0;
|
virtual void refresh(int x, int y, int w, int h) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Return number of bytes per pixel for a given pixel format
|
|
||||||
*/
|
|
||||||
static Genode::size_t bytes_per_pixel(Mode mode) { return 2; }
|
|
||||||
|
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
** RPC declaration **
|
** RPC declaration **
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
GENODE_RPC(Rpc_dataspace, Genode::Dataspace_capability, dataspace);
|
GENODE_RPC(Rpc_dataspace, Genode::Dataspace_capability, dataspace);
|
||||||
GENODE_RPC(Rpc_info, void, info, int *, int *, Mode *);
|
GENODE_RPC(Rpc_mode, Mode, mode);
|
||||||
GENODE_RPC(Rpc_refresh, void, refresh, int, int, int, int);
|
GENODE_RPC(Rpc_refresh, void, refresh, int, int, int, int);
|
||||||
|
|
||||||
GENODE_RPC_INTERFACE(Rpc_dataspace, Rpc_info, Rpc_refresh);
|
GENODE_RPC_INTERFACE(Rpc_dataspace, Rpc_mode, Rpc_refresh);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Nitpicker {
|
||||||
*/
|
*/
|
||||||
Session_capability
|
Session_capability
|
||||||
_connect(unsigned width, unsigned height, bool alpha,
|
_connect(unsigned width, unsigned height, bool alpha,
|
||||||
Framebuffer::Session::Mode mode, bool stay_top)
|
Framebuffer::Mode::Format format, bool stay_top)
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ namespace Nitpicker {
|
||||||
* probe for any valid video mode. For now, we just probe for
|
* probe for any valid video mode. For now, we just probe for
|
||||||
* RGB565.
|
* RGB565.
|
||||||
*/
|
*/
|
||||||
if (mode == Framebuffer::Session::INVALID)
|
if (format == Framebuffer::Mode::INVALID)
|
||||||
mode = Framebuffer::Session::RGB565;
|
format = Framebuffer::Mode::RGB565;
|
||||||
|
|
||||||
/* if buffer dimensions are specified, calculate ram quota to donate */
|
/* if buffer dimensions are specified, calculate ram quota to donate */
|
||||||
if (width && height)
|
if (width && height)
|
||||||
ram_quota = width*height*Framebuffer::Session::bytes_per_pixel(mode);
|
ram_quota = width*height*Framebuffer::Mode::bytes_per_pixel(format);
|
||||||
|
|
||||||
/* account for alpha and input-mask buffers */
|
/* account for alpha and input-mask buffers */
|
||||||
if (alpha)
|
if (alpha)
|
||||||
|
@ -74,8 +74,8 @@ namespace Nitpicker {
|
||||||
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_width", width);
|
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_width", width);
|
||||||
if (height)
|
if (height)
|
||||||
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_height", height);
|
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_height", height);
|
||||||
if (mode != Framebuffer::Session::INVALID)
|
if (format != Framebuffer::Mode::INVALID)
|
||||||
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_mode", mode);
|
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_format", format);
|
||||||
if (alpha)
|
if (alpha)
|
||||||
Arg_string::set_arg(argbuf, sizeof(argbuf), "alpha", "yes");
|
Arg_string::set_arg(argbuf, sizeof(argbuf), "alpha", "yes");
|
||||||
if (stay_top)
|
if (stay_top)
|
||||||
|
@ -92,18 +92,19 @@ namespace Nitpicker {
|
||||||
* \param width desired buffer width
|
* \param width desired buffer width
|
||||||
* \param height desired buffer height
|
* \param height desired buffer height
|
||||||
* \param alpha true for using a buffer with alpha channel
|
* \param alpha true for using a buffer with alpha channel
|
||||||
* \param mode desired pixel format
|
* \param format desired pixel format
|
||||||
*
|
*
|
||||||
* The specified value for 'mode' is not enforced. After creating the
|
* The specified value for 'format' is not enforced. After creating
|
||||||
* session, you should validate the actual pixel format of the
|
* the session, you should validate the actual pixel format of the
|
||||||
* buffer by its 'info'.
|
* buffer by its 'mode'.
|
||||||
*/
|
*/
|
||||||
Connection(unsigned width = 0, unsigned height = 0, bool alpha = false,
|
Connection(unsigned width = 0, unsigned height = 0, bool alpha = false,
|
||||||
Framebuffer::Session::Mode mode = Framebuffer::Session::INVALID,
|
Framebuffer::Mode::Format format = Framebuffer::Mode::INVALID,
|
||||||
bool stay_top = false)
|
bool stay_top = false)
|
||||||
:
|
:
|
||||||
/* establish nitpicker session */
|
/* establish nitpicker session */
|
||||||
Genode::Connection<Session>(_connect(width, height, alpha, mode, stay_top)),
|
Genode::Connection<Session>(_connect(width, height, alpha,
|
||||||
|
format, stay_top)),
|
||||||
Session_client(cap()),
|
Session_client(cap()),
|
||||||
|
|
||||||
/* request frame-buffer and input sub sessions */
|
/* request frame-buffer and input sub sessions */
|
||||||
|
|
|
@ -165,12 +165,7 @@ namespace Framebuffer
|
||||||
|
|
||||||
Genode::Dataspace_capability dataspace() { return _fb_ds_cap; }
|
Genode::Dataspace_capability dataspace() { return _fb_ds_cap; }
|
||||||
|
|
||||||
void info(int *out_w, int *out_h, Mode *out_mode)
|
Mode mode() { return Mode(SCR_WIDTH, SCR_HEIGHT, Mode::RGB565); }
|
||||||
{
|
|
||||||
*out_w = SCR_WIDTH;
|
|
||||||
*out_h = SCR_HEIGHT;
|
|
||||||
*out_mode = RGB565;
|
|
||||||
}
|
|
||||||
|
|
||||||
void refresh(int x, int y, int w, int h) { }
|
void refresh(int x, int y, int w, int h) { }
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
static SDL_Surface *screen;
|
static SDL_Surface *screen;
|
||||||
static int scr_width = 1024, scr_height = 768;
|
static int scr_width = 1024, scr_height = 768;
|
||||||
static Framebuffer::Session::Mode scr_mode = Framebuffer::Session::RGB565;
|
static Framebuffer::Mode::Format scr_format = Framebuffer::Mode::RGB565;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dataspace capability and local address of virtual frame buffer
|
* Dataspace capability and local address of virtual frame buffer
|
||||||
|
@ -57,16 +57,11 @@ namespace Framebuffer {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Session_component() : _mode(RGB565) { }
|
Session_component() : _mode(scr_width, scr_height, Mode::RGB565) { }
|
||||||
|
|
||||||
Genode::Dataspace_capability dataspace() { return fb_ds_cap; }
|
Genode::Dataspace_capability dataspace() { return fb_ds_cap; }
|
||||||
|
|
||||||
void info(int *out_w, int *out_h, Mode *out_mode)
|
Mode mode() { return _mode; }
|
||||||
{
|
|
||||||
*out_w = scr_width;
|
|
||||||
*out_h = scr_height;
|
|
||||||
*out_mode = _mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void refresh(int x, int y, int w, int h)
|
void refresh(int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
|
@ -79,9 +74,9 @@ namespace Framebuffer {
|
||||||
if (x1 > x2 || y1 > y2) return;
|
if (x1 > x2 || y1 > y2) return;
|
||||||
|
|
||||||
/* copy pixels from shared dataspace to sdl surface */
|
/* copy pixels from shared dataspace to sdl surface */
|
||||||
const int start_offset = bytes_per_pixel(_mode)*(y1*scr_width + x1);
|
const int start_offset = _mode.bytes_per_pixel()*(y1*scr_width + x1);
|
||||||
const int line_len = bytes_per_pixel(_mode)*(x2 - x1 + 1);
|
const int line_len = _mode.bytes_per_pixel()*(x2 - x1 + 1);
|
||||||
const int pitch = bytes_per_pixel(_mode)*scr_width;
|
const int pitch = _mode.bytes_per_pixel()*scr_width;
|
||||||
|
|
||||||
char *src = (char *)fb_ds_addr + start_offset;
|
char *src = (char *)fb_ds_addr + start_offset;
|
||||||
char *dst = (char *)screen->pixels + start_offset;
|
char *dst = (char *)screen->pixels + start_offset;
|
||||||
|
@ -138,11 +133,12 @@ extern "C" int main(int, char**)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Genode::size_t bpp = Framebuffer::Session::bytes_per_pixel(scr_mode);
|
Genode::size_t bpp = Framebuffer::Mode::bytes_per_pixel(scr_format);
|
||||||
screen = SDL_SetVideoMode(scr_width, scr_height, bpp*8, SDL_SWSURFACE);
|
screen = SDL_SetVideoMode(scr_width, scr_height, bpp*8, SDL_SWSURFACE);
|
||||||
SDL_ShowCursor(0);
|
SDL_ShowCursor(0);
|
||||||
|
|
||||||
Genode::printf("creating virtual framebuffer for mode %dx%d@%zd\n", scr_width, scr_height, bpp*8);
|
Genode::printf("creating virtual framebuffer for mode %dx%d@%zd\n",
|
||||||
|
scr_width, scr_height, bpp*8);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create dataspace representing the virtual frame buffer
|
* Create dataspace representing the virtual frame buffer
|
||||||
|
|
|
@ -150,15 +150,10 @@ namespace Framebuffer {
|
||||||
return _buffered ? Dataspace_capability(_bb_ds)
|
return _buffered ? Dataspace_capability(_bb_ds)
|
||||||
: Dataspace_capability(_fb_ds); }
|
: Dataspace_capability(_fb_ds); }
|
||||||
|
|
||||||
void info(int *out_w, int *out_h, Mode *out_mode)
|
Mode mode()
|
||||||
{
|
{
|
||||||
*out_w = _scr_width;
|
return Mode(_scr_width, _scr_height,
|
||||||
*out_h = _scr_height;
|
_scr_mode == 16 ? Mode::RGB565 : Mode::INVALID);
|
||||||
|
|
||||||
switch (_scr_mode) {
|
|
||||||
case 16: *out_mode = RGB565; break;
|
|
||||||
default: *out_mode = INVALID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not implemented */
|
/* not implemented */
|
||||||
|
|
|
@ -173,10 +173,8 @@ int main(int argc, char **argv)
|
||||||
*/
|
*/
|
||||||
if (view_w == 0 || view_h == 0) {
|
if (view_w == 0 || view_h == 0) {
|
||||||
Framebuffer::Session_client nit_fb(nitpicker.framebuffer_session());
|
Framebuffer::Session_client nit_fb(nitpicker.framebuffer_session());
|
||||||
int w = 0, h = 0;
|
Framebuffer::Mode const mode = nit_fb.mode();
|
||||||
Framebuffer::Session::Mode mode;
|
view_w = mode.width(), view_h = mode.height();
|
||||||
nit_fb.info(&w, &h, &mode);
|
|
||||||
view_w = w, view_h = h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PINF("using xywh=(%ld,%ld,%ld,%ld) refresh_rate=%ld",
|
PINF("using xywh=(%ld,%ld,%ld,%ld) refresh_rate=%ld",
|
||||||
|
|
|
@ -155,7 +155,7 @@ class Buffer
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Area _size;
|
Area _size;
|
||||||
Framebuffer::Session::Mode _mode;
|
Framebuffer::Mode::Format _format;
|
||||||
Genode::Attached_ram_dataspace _ram_ds;
|
Genode::Attached_ram_dataspace _ram_ds;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -166,8 +166,8 @@ class Buffer
|
||||||
* \throw Ram_session::Alloc_failed
|
* \throw Ram_session::Alloc_failed
|
||||||
* \throw Rm_session::Attach_failed
|
* \throw Rm_session::Attach_failed
|
||||||
*/
|
*/
|
||||||
Buffer(Area size, Framebuffer::Session::Mode mode, Genode::size_t bytes):
|
Buffer(Area size, Framebuffer::Mode::Format format, Genode::size_t bytes):
|
||||||
_size(size), _mode(mode),
|
_size(size), _format(format),
|
||||||
_ram_ds(Genode::env()->ram_session(), bytes)
|
_ram_ds(Genode::env()->ram_session(), bytes)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ class Buffer
|
||||||
*/
|
*/
|
||||||
Genode::Ram_dataspace_capability ds_cap() { return _ram_ds.cap(); }
|
Genode::Ram_dataspace_capability ds_cap() { return _ram_ds.cap(); }
|
||||||
Area size() { return _size; }
|
Area size() { return _size; }
|
||||||
Framebuffer::Session::Mode mode() { return _mode; }
|
Framebuffer::Mode::Format format() { return _format; }
|
||||||
void *local_addr() { return _ram_ds.local_addr<void>(); }
|
void *local_addr() { return _ram_ds.local_addr<void>(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -186,8 +186,8 @@ class Chunky_dataspace_texture : public Buffer, public Chunky_texture<PT>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Framebuffer::Session::Mode _mode() {
|
Framebuffer::Mode::Format _format() {
|
||||||
return Framebuffer::Session::RGB565; }
|
return Framebuffer::Mode::RGB565; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return base address of alpha channel or 0 if no alpha channel exists
|
* Return base address of alpha channel or 0 if no alpha channel exists
|
||||||
|
@ -206,7 +206,7 @@ class Chunky_dataspace_texture : public Buffer, public Chunky_texture<PT>
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Chunky_dataspace_texture(Area size, bool use_alpha):
|
Chunky_dataspace_texture(Area size, bool use_alpha):
|
||||||
Buffer(size, _mode(), calc_num_bytes(size, use_alpha)),
|
Buffer(size, _format(), calc_num_bytes(size, use_alpha)),
|
||||||
Chunky_texture<PT>((PT *)local_addr(),
|
Chunky_texture<PT>((PT *)local_addr(),
|
||||||
_alpha_base(size, use_alpha), size) { }
|
_alpha_base(size, use_alpha), size) { }
|
||||||
|
|
||||||
|
@ -341,11 +341,10 @@ namespace Framebuffer {
|
||||||
|
|
||||||
Genode::Dataspace_capability dataspace() { return _buffer->ds_cap(); }
|
Genode::Dataspace_capability dataspace() { return _buffer->ds_cap(); }
|
||||||
|
|
||||||
void info(int *out_w, int *out_h, Mode *out_mode)
|
Mode mode()
|
||||||
{
|
{
|
||||||
*out_w = _buffer->size().w();
|
return Mode(_buffer->size().w(), _buffer->size().h(),
|
||||||
*out_h = _buffer->size().h();
|
_buffer->format());
|
||||||
*out_mode = _buffer->mode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh(int x, int y, int w, int h)
|
void refresh(int x, int y, int w, int h)
|
||||||
|
@ -838,11 +837,10 @@ int main(int argc, char **argv)
|
||||||
/*
|
/*
|
||||||
* Initialize framebuffer
|
* Initialize framebuffer
|
||||||
*/
|
*/
|
||||||
int scr_w = 0, scr_h = 0;
|
Framebuffer::Mode const mode = framebuffer.mode();
|
||||||
Framebuffer::Session::Mode scr_mode = Framebuffer::Session::INVALID;
|
|
||||||
framebuffer.info(&scr_w, &scr_h, &scr_mode);
|
|
||||||
|
|
||||||
PINF("framebuffer is %dx%d@%d\n", scr_w, scr_h, scr_mode);
|
PINF("framebuffer is %dx%d@%d\n",
|
||||||
|
mode.width(), mode.height(), mode.format());
|
||||||
|
|
||||||
Dataspace_capability fb_ds_cap = framebuffer.dataspace();
|
Dataspace_capability fb_ds_cap = framebuffer.dataspace();
|
||||||
if (!fb_ds_cap.valid()) {
|
if (!fb_ds_cap.valid()) {
|
||||||
|
@ -851,11 +849,11 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
void *fb_base = env()->rm_session()->attach(fb_ds_cap);
|
void *fb_base = env()->rm_session()->attach(fb_ds_cap);
|
||||||
Screen<PT> screen((PT *)fb_base, Area(scr_w, scr_h));
|
Screen<PT> screen((PT *)fb_base, Area(mode.width(), mode.height()));
|
||||||
|
|
||||||
enum { MENUBAR_HEIGHT = 16 };
|
enum { MENUBAR_HEIGHT = 16 };
|
||||||
PT *menubar_pixels = (PT *)env()->heap()->alloc(sizeof(PT)*scr_w*16);
|
PT *menubar_pixels = (PT *)env()->heap()->alloc(sizeof(PT)*mode.width()*16);
|
||||||
Chunky_menubar<PT> menubar(menubar_pixels, Area(scr_w, MENUBAR_HEIGHT));
|
Chunky_menubar<PT> menubar(menubar_pixels, Area(mode.width(), MENUBAR_HEIGHT));
|
||||||
|
|
||||||
User_state user_state(&screen, &menubar);
|
User_state user_state(&screen, &menubar);
|
||||||
|
|
||||||
|
@ -881,7 +879,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
Sliced_heap sliced_heap(env()->ram_session(), env()->rm_session());
|
Sliced_heap sliced_heap(env()->ram_session(), env()->rm_session());
|
||||||
|
|
||||||
static Nitpicker::Root<PT> np_root(&ep, Area(scr_w, scr_h),
|
static Nitpicker::Root<PT> np_root(&ep, Area(mode.width(), mode.height()),
|
||||||
&user_state, &sliced_heap,
|
&user_state, &sliced_heap,
|
||||||
&screen, &framebuffer,
|
&screen, &framebuffer,
|
||||||
MENUBAR_HEIGHT);
|
MENUBAR_HEIGHT);
|
||||||
|
|
|
@ -115,9 +115,8 @@ int main(int argc, char **argv)
|
||||||
static Nitpicker::Connection nitpicker(256, 256, CONFIG_ALPHA);
|
static Nitpicker::Connection nitpicker(256, 256, CONFIG_ALPHA);
|
||||||
static Timer::Connection timer;
|
static Timer::Connection timer;
|
||||||
|
|
||||||
int scr_w = 0, scr_h = 0;
|
Framebuffer::Mode const mode = nitpicker.framebuffer()->mode();
|
||||||
Framebuffer::Session::Mode scr_mode;
|
int const scr_w = mode.width(), scr_h = mode.height();
|
||||||
nitpicker.framebuffer()->info(&scr_w, &scr_h, &scr_mode);
|
|
||||||
|
|
||||||
printf("screen is %dx%d\n", scr_w, scr_h);
|
printf("screen is %dx%d\n", scr_w, scr_h);
|
||||||
if (!scr_w || !scr_h) {
|
if (!scr_w || !scr_h) {
|
||||||
|
|
|
@ -66,8 +66,9 @@ extern "C" {
|
||||||
{
|
{
|
||||||
Linux::Irq_guard guard;
|
Linux::Irq_guard guard;
|
||||||
|
|
||||||
Framebuffer::Session::Mode dummy;
|
Framebuffer::Mode const mode = framebuffer()->mode();
|
||||||
framebuffer()->info(out_w, out_h, &dummy);
|
*out_w = mode.width();
|
||||||
|
*out_h = mode.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,9 @@ extern "C" {
|
||||||
{
|
{
|
||||||
Screen *s = Screen_array::screens()->get(screen);
|
Screen *s = Screen_array::screens()->get(screen);
|
||||||
if (s && s->framebuffer()) {
|
if (s && s->framebuffer()) {
|
||||||
Framebuffer::Session::Mode dummy;
|
Framebuffer::Mode const mode = s->framebuffer()->mode();
|
||||||
s->framebuffer()->info(out_w, out_h, &dummy);
|
*out_w = mode.width();
|
||||||
|
*out_h = mode.height();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,9 +173,8 @@ bool QNitpickerScreen::connect(const QString &displaySpec)
|
||||||
nitpicker = new Nitpicker::Connection();
|
nitpicker = new Nitpicker::Connection();
|
||||||
framebuffer = new Framebuffer::Session_client(nitpicker->framebuffer_session());
|
framebuffer = new Framebuffer::Session_client(nitpicker->framebuffer_session());
|
||||||
|
|
||||||
int scr_w = 0, scr_h = 0;
|
Framebuffer::Mode const scr_mode = framebuffer->mode();
|
||||||
Framebuffer::Session::Mode scr_mode;
|
int const scr_w = scr_mode.width(), scr_h = scr_mode.height();
|
||||||
framebuffer->info(&scr_w, &scr_h, &scr_mode);
|
|
||||||
|
|
||||||
qDebug() << "screen is " << scr_w << "x" << scr_h;
|
qDebug() << "screen is " << scr_w << "x" << scr_h;
|
||||||
if (!scr_w || !scr_h) {
|
if (!scr_w || !scr_h) {
|
||||||
|
|
Loading…
Reference in New Issue