diff --git a/demo/src/app/backdrop/main.cc b/demo/src/app/backdrop/main.cc index e2769f9d9..a7d984d53 100644 --- a/demo/src/app/backdrop/main.cc +++ b/demo/src/app/backdrop/main.cc @@ -234,16 +234,14 @@ int main(int argc, char **argv) static Nitpicker::Connection nitpicker; 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(); static Nitpicker::View_client view(view_cap); /* obtain screen size */ - framebuffer.info(&fb_width, &fb_height, &fb_mode); + Framebuffer::Mode const mode = framebuffer.mode(); - if (fb_mode != Framebuffer::Session::RGB565) { - printf("Error: Color mode %d not supported\n", (int)fb_mode); + if (mode.format() != Framebuffer::Mode::RGB565) { + printf("Error: Color mode %d not supported\n", (int)mode.format()); return -3; } @@ -251,13 +249,13 @@ int main(int argc, char **argv) uint16_t *fb = env()->rm_session()->attach(framebuffer.dataspace()); /* 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 */ 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); - framebuffer.refresh(0, 0, fb_width, fb_height); + framebuffer.refresh(0, 0, mode.width(), mode.height()); sleep_forever(); return 0; diff --git a/demo/src/app/scout/genode/platform_genode.cc b/demo/src/app/scout/genode/platform_genode.cc index 601d77a48..4754ddc36 100644 --- a/demo/src/app/scout/genode/platform_genode.cc +++ b/demo/src/app/scout/genode/platform_genode.cc @@ -27,7 +27,7 @@ static int _scr_w; static int _scr_h; -static Framebuffer::Session::Mode _scr_mode; +static Framebuffer::Mode::Format _scr_format; static Input::Event *_ev_buf; static char *_scr_adr; static char *_buf_adr; @@ -221,7 +221,10 @@ Platform::Platform(unsigned vx, unsigned vy, unsigned vw, unsigned vh, * propagated to different nitpicker instances. */ _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); 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 * 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; _timer = &timer; - int dummy = 0; - _nitpicker->framebuffer()->info(&dummy, &dummy, &_scr_mode); + Framebuffer::Mode const used_mode = _nitpicker->framebuffer()->mode(); /* * We use the upper half the allocated nitpicker buffer for '_scr_adr' * and the lower half for '_buf_adr'. */ - _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); - _ev_buf = env()->rm_session()->attach(_nitpicker->input()->dataspace()); + _scr_adr = env()->rm_session()->attach(_nitpicker->framebuffer()->dataspace()); + _buf_adr = (char *)_scr_adr + _scr_w*_scr_h*used_mode.bytes_per_pixel(); + _ev_buf = env()->rm_session()->attach(_nitpicker->input()->dataspace()); 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) { - 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 */ int len = w*bpp; diff --git a/demo/src/server/liquid_framebuffer/services.cc b/demo/src/server/liquid_framebuffer/services.cc index 0b7effc86..0c797450d 100644 --- a/demo/src/server/liquid_framebuffer/services.cc +++ b/demo/src/server/liquid_framebuffer/services.cc @@ -198,11 +198,10 @@ namespace Framebuffer 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(); - *out_h = _window_content->fb_h(); - *out_mode = RGB565; + return Mode(_window_content->fb_w(), _window_content->fb_h(), + Mode::RGB565); } void refresh(int x, int y, int w, int h) { diff --git a/gems/src/server/terminal/main.cc b/gems/src/server/terminal/main.cc index bb8bc60e4..44f7551aa 100644 --- a/gems/src/server/terminal/main.cc +++ b/gems/src/server/terminal/main.cc @@ -784,14 +784,12 @@ namespace Terminal { Genode::Attached_ram_dataspace _io_buffer; - int _fb_width; - int _fb_height; + Framebuffer::Mode _fb_mode; Genode::Dataspace_capability _fb_ds_cap; unsigned _char_width; unsigned _char_height; unsigned _columns; unsigned _lines; - Framebuffer::Session::Mode _fb_mode; void *_fb_addr; /** @@ -810,10 +808,8 @@ namespace Terminal { */ Genode::Dataspace_capability _init_fb() { - _framebuffer->info(&_fb_width, &_fb_height, &_fb_mode); - - if (_fb_mode != Framebuffer::Session::RGB565) { - PERR("Color mode %d not supported", _fb_mode); + if (_fb_mode.format() != Framebuffer::Mode::RGB565) { + PERR("Color mode %d not supported", _fb_mode.format()); return Genode::Dataspace_capability(); } @@ -830,6 +826,7 @@ namespace Terminal { Genode::size_t io_buffer_size) : _read_buffer(read_buffer), _framebuffer(framebuffer), _io_buffer(Genode::env()->ram_session(), io_buffer_size), + _fb_mode(_framebuffer->mode()), _fb_ds_cap(_init_fb()), /* take size of space character as character cell size */ @@ -837,8 +834,8 @@ namespace Terminal { _char_height(mono_font.str_h("m")), /* compute number of characters fitting on the framebuffer */ - _columns(_fb_width/_char_width), - _lines(_fb_height/_char_height), + _columns(_fb_mode.width()/_char_width), + _lines(_fb_mode.height()/_char_height), _fb_addr(Genode::env()->rm_session()->attach(_fb_ds_cap)), _char_cell_array(_columns, _lines, Genode::env()->heap()), @@ -848,11 +845,11 @@ namespace Terminal { using namespace Genode; 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(" 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() @@ -861,8 +858,8 @@ namespace Terminal { convert_char_array_to_pixels(&_char_cell_array, (Pixel_rgb565 *)_fb_addr, - _fb_width, - _fb_height); + _fb_mode.width(), + _fb_mode.height()); int first_dirty_line = 10000, @@ -880,7 +877,7 @@ namespace Terminal { int num_dirty_lines = last_dirty_line - first_dirty_line + 1; _framebuffer->refresh(0, first_dirty_line*_char_height, - _fb_width, num_dirty_lines*_char_height); + _fb_mode.width(), num_dirty_lines*_char_height); } diff --git a/libports/src/lib/egl/driver.cc b/libports/src/lib/egl/driver.cc index e4f162c55..098e74cb8 100644 --- a/libports/src/lib/egl/driver.cc +++ b/libports/src/lib/egl/driver.cc @@ -61,20 +61,19 @@ class Genode_framebuffer { private: - Framebuffer::Connection _framebuffer; - int _width, _height; - Framebuffer::Session::Mode _mode; - Genode::Dataspace_capability _ds_cap; - void *_local_addr; + Framebuffer::Connection _framebuffer; + Framebuffer::Mode const _mode; + Genode::Dataspace_capability const _ds_cap; + void * const _local_addr; public: Genode_framebuffer() - { - _framebuffer.info(&_width, &_height, &_mode); - _ds_cap = _framebuffer.dataspace(); - _local_addr = Genode::env()->rm_session()->attach(_ds_cap); - } + : + _mode(_framebuffer.mode()), + _ds_cap(_framebuffer.dataspace()), + _local_addr(Genode::env()->rm_session()->attach(_ds_cap)) + { } ~Genode_framebuffer() { @@ -85,11 +84,11 @@ class Genode_framebuffer void flush() { - _framebuffer.refresh(0, 0, _width, _height); + _framebuffer.refresh(0, 0, _mode.width(), _mode.height()); } - int width() const { return _width; } - int height() const { return _height; } + int width() const { return _mode.width(); } + int height() const { return _mode.height(); } }; diff --git a/libports/src/lib/sdl/video/SDL_genode_fb_video.cc b/libports/src/lib/sdl/video/SDL_genode_fb_video.cc index 06576841d..de64d3371 100644 --- a/libports/src/lib/sdl/video/SDL_genode_fb_video.cc +++ b/libports/src/lib/sdl/video/SDL_genode_fb_video.cc @@ -44,9 +44,7 @@ extern "C" { #include "SDL_genode_fb_video.h" static Framebuffer::Connection *framebuffer = 0; - static Framebuffer::Session::Mode scr_mode = Framebuffer::Session::INVALID; - static int width = 0; - static int height = 0; + static Framebuffer::Mode scr_mode; static SDL_Rect *modes[2]; static SDL_Rect df_mode; @@ -156,19 +154,19 @@ extern "C" { } /* Get the framebuffer size and mode infos */ - framebuffer->info(&width, &height, &scr_mode); - t->info.current_w = width; - t->info.current_h = height; + scr_mode = framebuffer->mode(); + t->info.current_w = scr_mode.width(); + t->info.current_h = scr_mode.height(); PDBG("Framebuffer has width=%d and height=%d", t->info.current_w, t->info.current_h); /* set mode specific values */ - switch(scr_mode) + switch(scr_mode.format()) { - case Framebuffer::Session::RGB565: + case Framebuffer::Mode::RGB565: PDBG("We use pixelformat rgb565."); vformat->BitsPerPixel = 16; - vformat->BytesPerPixel = 2; + vformat->BytesPerPixel = scr_mode.bytes_per_pixel(); vformat->Rmask = 0x0000f800; vformat->Gmask = 0x000007e0; vformat->Bmask = 0x0000001f; @@ -179,8 +177,8 @@ extern "C" { return -1; } modes[0] = &df_mode; - df_mode.w = width; - df_mode.h = height; + df_mode.w = scr_mode.width(); + df_mode.h = scr_mode.height(); modes[1] = 0; /* Map the buffer */ diff --git a/os/include/framebuffer_session/client.h b/os/include/framebuffer_session/client.h index 1fa97ab57..1d147cc83 100644 --- a/os/include/framebuffer_session/client.h +++ b/os/include/framebuffer_session/client.h @@ -27,8 +27,8 @@ namespace Framebuffer { Genode::Dataspace_capability dataspace() { return call(); } - void info(int *out_w, int *out_h, Mode *out_mode) { - call(out_w, out_h, out_mode); } + Mode mode() { + return call(); } void refresh(int x, int y, int w, int h) { call(x, y, w, h); } diff --git a/os/include/framebuffer_session/connection.h b/os/include/framebuffer_session/connection.h index 28d3fa853..0d69a74b2 100644 --- a/os/include/framebuffer_session/connection.h +++ b/os/include/framebuffer_session/connection.h @@ -28,7 +28,8 @@ namespace Framebuffer { /** * 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; @@ -43,8 +44,8 @@ namespace Framebuffer { Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_width", width); if (height) Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_height", height); - if (mode != Session::INVALID) - Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_mode", mode); + if (format != Mode::INVALID) + Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_format", format); return session(argbuf); } @@ -62,11 +63,11 @@ namespace Framebuffer { * session, you should validate the actual frame-buffer attributes * by calling the 'info' function of the frame-buffer interface. */ - Connection(unsigned width = 0, - unsigned height = 0, - Mode mode = INVALID) + Connection(unsigned width = 0, + unsigned height = 0, + Mode::Format format = Mode::INVALID) : - Genode::Connection(_connect(width, height, mode)), + Genode::Connection(_connect(width, height, format)), Session_client(cap()) { } }; diff --git a/os/include/framebuffer_session/framebuffer_session.h b/os/include/framebuffer_session/framebuffer_session.h index f2ad4af2b..07803fbff 100644 --- a/os/include/framebuffer_session/framebuffer_session.h +++ b/os/include/framebuffer_session/framebuffer_session.h @@ -19,15 +19,48 @@ 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 { static const char *service_name() { return "Framebuffer"; } - /** - * Pixel formats - */ - enum Mode { INVALID, RGB565 }; - virtual ~Session() { } /** @@ -37,12 +70,8 @@ namespace Framebuffer { /** * 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 @@ -51,21 +80,16 @@ namespace Framebuffer { */ 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 ** *********************/ 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_INTERFACE(Rpc_dataspace, Rpc_info, Rpc_refresh); + GENODE_RPC_INTERFACE(Rpc_dataspace, Rpc_mode, Rpc_refresh); }; } diff --git a/os/include/nitpicker_session/connection.h b/os/include/nitpicker_session/connection.h index 7ca883400..c6178fded 100644 --- a/os/include/nitpicker_session/connection.h +++ b/os/include/nitpicker_session/connection.h @@ -35,7 +35,7 @@ namespace Nitpicker { */ Session_capability _connect(unsigned width, unsigned height, bool alpha, - Framebuffer::Session::Mode mode, bool stay_top) + Framebuffer::Mode::Format format, bool stay_top) { using namespace Genode; @@ -51,12 +51,12 @@ namespace Nitpicker { * probe for any valid video mode. For now, we just probe for * RGB565. */ - if (mode == Framebuffer::Session::INVALID) - mode = Framebuffer::Session::RGB565; + if (format == Framebuffer::Mode::INVALID) + format = Framebuffer::Mode::RGB565; /* if buffer dimensions are specified, calculate ram quota to donate */ 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 */ if (alpha) @@ -74,8 +74,8 @@ namespace Nitpicker { Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_width", width); if (height) Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_height", height); - if (mode != Framebuffer::Session::INVALID) - Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_mode", mode); + if (format != Framebuffer::Mode::INVALID) + Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_format", format); if (alpha) Arg_string::set_arg(argbuf, sizeof(argbuf), "alpha", "yes"); if (stay_top) @@ -92,18 +92,19 @@ namespace Nitpicker { * \param width desired buffer width * \param height desired buffer height * \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 - * session, you should validate the actual pixel format of the - * buffer by its 'info'. + * The specified value for 'format' is not enforced. After creating + * the session, you should validate the actual pixel format of the + * buffer by its 'mode'. */ 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) : /* establish nitpicker session */ - Genode::Connection(_connect(width, height, alpha, mode, stay_top)), + Genode::Connection(_connect(width, height, alpha, + format, stay_top)), Session_client(cap()), /* request frame-buffer and input sub sessions */ diff --git a/os/src/drivers/framebuffer/pl11x/main.cc b/os/src/drivers/framebuffer/pl11x/main.cc index 5299a2109..224d369e7 100644 --- a/os/src/drivers/framebuffer/pl11x/main.cc +++ b/os/src/drivers/framebuffer/pl11x/main.cc @@ -165,12 +165,7 @@ namespace Framebuffer Genode::Dataspace_capability dataspace() { return _fb_ds_cap; } - void info(int *out_w, int *out_h, Mode *out_mode) - { - *out_w = SCR_WIDTH; - *out_h = SCR_HEIGHT; - *out_mode = RGB565; - } + Mode mode() { return Mode(SCR_WIDTH, SCR_HEIGHT, Mode::RGB565); } void refresh(int x, int y, int w, int h) { } }; diff --git a/os/src/drivers/framebuffer/sdl/fb_sdl.cc b/os/src/drivers/framebuffer/sdl/fb_sdl.cc index 6ec02b6ad..a450b73c3 100644 --- a/os/src/drivers/framebuffer/sdl/fb_sdl.cc +++ b/os/src/drivers/framebuffer/sdl/fb_sdl.cc @@ -30,7 +30,7 @@ */ static SDL_Surface *screen; 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 @@ -57,16 +57,11 @@ namespace Framebuffer { /** * Constructor */ - Session_component() : _mode(RGB565) { } + Session_component() : _mode(scr_width, scr_height, Mode::RGB565) { } Genode::Dataspace_capability dataspace() { return fb_ds_cap; } - void info(int *out_w, int *out_h, Mode *out_mode) - { - *out_w = scr_width; - *out_h = scr_height; - *out_mode = _mode; - } + Mode mode() { return _mode; } void refresh(int x, int y, int w, int h) { @@ -79,9 +74,9 @@ namespace Framebuffer { if (x1 > x2 || y1 > y2) return; /* copy pixels from shared dataspace to sdl surface */ - const int start_offset = bytes_per_pixel(_mode)*(y1*scr_width + x1); - const int line_len = bytes_per_pixel(_mode)*(x2 - x1 + 1); - const int pitch = bytes_per_pixel(_mode)*scr_width; + const int start_offset = _mode.bytes_per_pixel()*(y1*scr_width + x1); + const int line_len = _mode.bytes_per_pixel()*(x2 - x1 + 1); + const int pitch = _mode.bytes_per_pixel()*scr_width; char *src = (char *)fb_ds_addr + start_offset; char *dst = (char *)screen->pixels + start_offset; @@ -138,11 +133,12 @@ extern "C" int main(int, char**) 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); 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 diff --git a/os/src/drivers/framebuffer/vesa/main.cc b/os/src/drivers/framebuffer/vesa/main.cc index 28e3e735b..9deea9b26 100644 --- a/os/src/drivers/framebuffer/vesa/main.cc +++ b/os/src/drivers/framebuffer/vesa/main.cc @@ -150,15 +150,10 @@ namespace Framebuffer { return _buffered ? Dataspace_capability(_bb_ds) : Dataspace_capability(_fb_ds); } - void info(int *out_w, int *out_h, Mode *out_mode) + Mode mode() { - *out_w = _scr_width; - *out_h = _scr_height; - - switch (_scr_mode) { - case 16: *out_mode = RGB565; break; - default: *out_mode = INVALID; - } + return Mode(_scr_width, _scr_height, + _scr_mode == 16 ? Mode::RGB565 : Mode::INVALID); } /* not implemented */ diff --git a/os/src/server/nit_fb/main.cc b/os/src/server/nit_fb/main.cc index 68b34d12a..8221d4973 100644 --- a/os/src/server/nit_fb/main.cc +++ b/os/src/server/nit_fb/main.cc @@ -173,10 +173,8 @@ int main(int argc, char **argv) */ if (view_w == 0 || view_h == 0) { Framebuffer::Session_client nit_fb(nitpicker.framebuffer_session()); - int w = 0, h = 0; - Framebuffer::Session::Mode mode; - nit_fb.info(&w, &h, &mode); - view_w = w, view_h = h; + Framebuffer::Mode const mode = nit_fb.mode(); + view_w = mode.width(), view_h = mode.height(); } PINF("using xywh=(%ld,%ld,%ld,%ld) refresh_rate=%ld", diff --git a/os/src/server/nitpicker/genode/main.cc b/os/src/server/nitpicker/genode/main.cc index f59797f62..f20447093 100644 --- a/os/src/server/nitpicker/genode/main.cc +++ b/os/src/server/nitpicker/genode/main.cc @@ -155,7 +155,7 @@ class Buffer private: Area _size; - Framebuffer::Session::Mode _mode; + Framebuffer::Mode::Format _format; Genode::Attached_ram_dataspace _ram_ds; public: @@ -166,8 +166,8 @@ class Buffer * \throw Ram_session::Alloc_failed * \throw Rm_session::Attach_failed */ - Buffer(Area size, Framebuffer::Session::Mode mode, Genode::size_t bytes): - _size(size), _mode(mode), + Buffer(Area size, Framebuffer::Mode::Format format, Genode::size_t bytes): + _size(size), _format(format), _ram_ds(Genode::env()->ram_session(), bytes) { } @@ -176,7 +176,7 @@ class Buffer */ Genode::Ram_dataspace_capability ds_cap() { return _ram_ds.cap(); } Area size() { return _size; } - Framebuffer::Session::Mode mode() { return _mode; } + Framebuffer::Mode::Format format() { return _format; } void *local_addr() { return _ram_ds.local_addr(); } }; @@ -186,8 +186,8 @@ class Chunky_dataspace_texture : public Buffer, public Chunky_texture { private: - Framebuffer::Session::Mode _mode() { - return Framebuffer::Session::RGB565; } + Framebuffer::Mode::Format _format() { + return Framebuffer::Mode::RGB565; } /** * 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 * Constructor */ 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 *)local_addr(), _alpha_base(size, use_alpha), size) { } @@ -341,11 +341,10 @@ namespace Framebuffer { 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(); - *out_h = _buffer->size().h(); - *out_mode = _buffer->mode(); + return Mode(_buffer->size().w(), _buffer->size().h(), + _buffer->format()); } void refresh(int x, int y, int w, int h) @@ -838,11 +837,10 @@ int main(int argc, char **argv) /* * Initialize framebuffer */ - int scr_w = 0, scr_h = 0; - Framebuffer::Session::Mode scr_mode = Framebuffer::Session::INVALID; - framebuffer.info(&scr_w, &scr_h, &scr_mode); + Framebuffer::Mode const mode = framebuffer.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(); 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); - Screen screen((PT *)fb_base, Area(scr_w, scr_h)); + Screen screen((PT *)fb_base, Area(mode.width(), mode.height())); enum { MENUBAR_HEIGHT = 16 }; - PT *menubar_pixels = (PT *)env()->heap()->alloc(sizeof(PT)*scr_w*16); - Chunky_menubar menubar(menubar_pixels, Area(scr_w, MENUBAR_HEIGHT)); + PT *menubar_pixels = (PT *)env()->heap()->alloc(sizeof(PT)*mode.width()*16); + Chunky_menubar menubar(menubar_pixels, Area(mode.width(), MENUBAR_HEIGHT)); 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()); - static Nitpicker::Root np_root(&ep, Area(scr_w, scr_h), + static Nitpicker::Root np_root(&ep, Area(mode.width(), mode.height()), &user_state, &sliced_heap, &screen, &framebuffer, MENUBAR_HEIGHT); diff --git a/os/src/test/nitpicker/test.cc b/os/src/test/nitpicker/test.cc index ffd11a807..ea91fddd4 100644 --- a/os/src/test/nitpicker/test.cc +++ b/os/src/test/nitpicker/test.cc @@ -115,9 +115,8 @@ int main(int argc, char **argv) static Nitpicker::Connection nitpicker(256, 256, CONFIG_ALPHA); static Timer::Connection timer; - int scr_w = 0, scr_h = 0; - Framebuffer::Session::Mode scr_mode; - nitpicker.framebuffer()->info(&scr_w, &scr_h, &scr_mode); + Framebuffer::Mode const mode = nitpicker.framebuffer()->mode(); + int const scr_w = mode.width(), scr_h = mode.height(); printf("screen is %dx%d\n", scr_w, scr_h); if (!scr_w || !scr_h) { diff --git a/ports-foc/src/lib/l4lx/genode_framebuffer.cc b/ports-foc/src/lib/l4lx/genode_framebuffer.cc index 620f4485a..f12c3d6a2 100644 --- a/ports-foc/src/lib/l4lx/genode_framebuffer.cc +++ b/ports-foc/src/lib/l4lx/genode_framebuffer.cc @@ -66,8 +66,9 @@ extern "C" { { Linux::Irq_guard guard; - Framebuffer::Session::Mode dummy; - framebuffer()->info(out_w, out_h, &dummy); + Framebuffer::Mode const mode = framebuffer()->mode(); + *out_w = mode.width(); + *out_h = mode.height(); } diff --git a/ports-okl4/src/lib/oklx/genode/genode_framebuffer.cc b/ports-okl4/src/lib/oklx/genode/genode_framebuffer.cc index f0e61a668..12c0a6a9e 100644 --- a/ports-okl4/src/lib/oklx/genode/genode_framebuffer.cc +++ b/ports-okl4/src/lib/oklx/genode/genode_framebuffer.cc @@ -82,8 +82,9 @@ extern "C" { { Screen *s = Screen_array::screens()->get(screen); if (s && s->framebuffer()) { - Framebuffer::Session::Mode dummy; - s->framebuffer()->info(out_w, out_h, &dummy); + Framebuffer::Mode const mode = s->framebuffer()->mode(); + *out_w = mode.width(); + *out_h = mode.height(); } } diff --git a/qt4/src/lib/qt4/src/gui/embedded/qscreennitpicker_qws.cpp b/qt4/src/lib/qt4/src/gui/embedded/qscreennitpicker_qws.cpp index adae277c1..439485048 100644 --- a/qt4/src/lib/qt4/src/gui/embedded/qscreennitpicker_qws.cpp +++ b/qt4/src/lib/qt4/src/gui/embedded/qscreennitpicker_qws.cpp @@ -173,9 +173,8 @@ bool QNitpickerScreen::connect(const QString &displaySpec) nitpicker = new Nitpicker::Connection(); framebuffer = new Framebuffer::Session_client(nitpicker->framebuffer_session()); - int scr_w = 0, scr_h = 0; - Framebuffer::Session::Mode scr_mode; - framebuffer->info(&scr_w, &scr_h, &scr_mode); + Framebuffer::Mode const scr_mode = framebuffer->mode(); + int const scr_w = scr_mode.width(), scr_h = scr_mode.height(); qDebug() << "screen is " << scr_w << "x" << scr_h; if (!scr_w || !scr_h) {