From ef741ef80d477ae7052fca1d1bb7272c40ae4d6e Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 16 Jun 2020 15:46:59 +0200 Subject: [PATCH] Change pixel format to 32 bits per pixel Until now, Genode's framebuffer session interface was based on the RGB565 pixel format. This patch changes the pixel format to 32-bit XRGB where the X part is ignored. It adapts all graphical applications and device drivers accordingly. The patch also adjusts the users of the drivers_interactive packages, assigning 64 MiB RAM and 1500 caps to the drivers subsystem, which is sufficient for covering high resolutions at 32 bits per pixel and to accommodate multi-component USB HID input stacks. Fixes #3784 --- .../recipes/src/imx8_fb_drv/used_apis | 1 + .../framebuffer/imx8/include/component.h | 33 +++--- .../src/drivers/framebuffer/imx8/target.mk | 2 +- .../framebuffer/intel/include/component.h | 15 ++- .../src/drivers/framebuffer/intel/lx_emul_c.c | 2 +- repos/demo/include/scout/canvas.h | 2 +- .../include/scout/graphics_backend_impl.h | 14 ++- .../src/app/launchpad/launchpad_window.cc | 2 +- repos/demo/src/app/launchpad/main.cc | 2 +- repos/demo/src/app/scout/browser_window.cc | 2 +- repos/demo/src/app/scout/doc.cc | 2 +- repos/demo/src/app/scout/main.cc | 6 +- repos/demo/src/app/scout/png_image.cc | 1 + repos/demo/src/app/scout/scrollbar.cc | 2 +- repos/demo/src/app/scout/widgets.cc | 10 +- .../src/server/liquid_framebuffer/main.cc | 6 +- .../src/server/liquid_framebuffer/services.cc | 15 ++- repos/demo/src/server/nitlog/main.cc | 7 +- repos/gems/include/gems/gui_buffer.h | 15 +-- repos/gems/include/nano3d/scene.h | 10 +- repos/gems/run/cpu_load_display.run | 4 +- repos/gems/run/decorator.run | 4 +- repos/gems/run/decorator_stress.run | 4 +- repos/gems/run/depot_deploy.run | 4 +- repos/gems/run/gui_fader.run | 10 +- repos/gems/run/leitzentrale.run | 4 +- repos/gems/run/menu_view.run | 4 +- repos/gems/run/nano3d.run | 4 +- repos/gems/run/terminal_echo.run | 4 +- repos/gems/run/terminal_log.run | 4 +- repos/gems/run/text_area.run | 4 +- repos/gems/run/text_painter.run | 4 +- repos/gems/run/wm.run | 4 +- repos/gems/src/app/backdrop/main.cc | 27 ++--- repos/gems/src/app/cpu_load_display/main.cc | 4 +- repos/gems/src/app/decorator/main.cc | 12 +- repos/gems/src/app/decorator/texture_by_id.cc | 6 +- repos/gems/src/app/menu_view/types.h | 1 - repos/gems/src/app/nano3d/main.cc | 4 +- repos/gems/src/app/sculpt_manager/main.cc | 16 +-- repos/gems/src/app/themed_decorator/theme.h | 2 - repos/gems/src/app/themed_decorator/window.h | 10 +- repos/gems/src/app/window_layouter/main.cc | 2 +- repos/gems/src/server/gui_fader/main.cc | 16 +-- repos/gems/src/server/terminal/framebuffer.h | 13 +-- repos/gems/src/server/terminal/main.cc | 2 +- .../src/server/terminal/text_screen_surface.h | 2 +- repos/gems/src/server/wm/gui.h | 8 +- repos/gems/src/test/driver_manager/main.cc | 2 +- repos/gems/src/test/text_painter/main.cc | 9 +- repos/libports/run/mesa.inc | 4 +- repos/libports/run/mupdf.run | 4 +- repos/libports/run/qt5_common.inc | 2 +- repos/libports/run/qt5_drivers.inc | 2 +- repos/libports/src/app/pdf_view/main.cc | 107 +++++------------- .../src/drivers/framebuffer/vesa/README | 30 +---- .../src/drivers/framebuffer/vesa/main.cc | 15 +-- .../src/lib/mesa/i965/platform_i965.c | 16 ++- .../src/lib/mesa/swrast/platform_swrast.c | 15 ++- .../genode/qgenodeplatformwindow.cpp | 14 +-- .../plugins/platforms/genode/qgenodescreen.h | 11 +- .../src/test/mesa_demo/eglut/eglut_genode.cc | 14 ++- .../include/framebuffer_session/connection.h | 17 +-- .../framebuffer_session/framebuffer_session.h | 55 +-------- repos/os/include/gui_session/gui_session.h | 2 +- repos/os/include/os/pixel_rgb888.h | 11 +- .../drivers_interactive-linux/drivers.config | 2 +- .../drivers_interactive-muen/drivers.config | 4 +- .../raw/drivers_interactive-pc/drivers.config | 2 +- repos/os/recipes/src/boot_fb_drv/used_apis | 1 + repos/os/run/demo.run | 12 +- repos/os/run/fb_bench.run | 2 +- repos/os/run/framebuffer.run | 4 +- repos/os/run/loader.run | 4 +- repos/os/src/app/pointer/main.cc | 21 ++-- repos/os/src/app/status_bar/main.cc | 16 +-- .../drivers/framebuffer/boot/framebuffer.cc | 37 +++--- .../os/src/drivers/framebuffer/boot/target.mk | 2 +- .../os/src/drivers/framebuffer/pl11x/main.cc | 19 ++-- .../drivers/framebuffer/spec/imx53/driver.h | 2 +- .../src/drivers/framebuffer/spec/imx53/ipu.h | 17 +-- .../drivers/framebuffer/spec/imx53/main.cc | 12 +- .../src/drivers/framebuffer/spec/rpi/README | 2 + .../src/drivers/framebuffer/spec/rpi/main.cc | 8 +- .../src/drivers/framebuffer/spec/sdl/main.cc | 24 ++-- repos/os/src/server/gui_fb/main.cc | 47 ++++---- repos/os/src/server/loader/gui.h | 15 ++- repos/os/src/server/nitpicker/buffer.h | 17 ++- .../os/src/server/nitpicker/chunky_texture.h | 5 +- repos/os/src/server/nitpicker/main.cc | 8 +- .../src/server/nitpicker/session_component.cc | 19 +--- .../src/server/nitpicker/session_component.h | 2 +- .../os/src/server/nitpicker/view_component.cc | 2 +- repos/os/src/test/fb_bench/main.cc | 10 +- repos/os/src/test/framebuffer/main.cc | 58 ++++------ repos/os/src/test/nitpicker/test.cc | 10 +- repos/ports/recipes/src/vbox5-nova/used_apis | 2 + repos/ports/recipes/src/vbox5/used_apis | 2 + repos/ports/run/bash.run | 4 +- repos/ports/run/debug_nitpicker.run | 4 +- repos/ports/run/seoul-fancy.run | 2 +- repos/ports/run/seoul.inc | 4 +- repos/ports/run/vbox5_genode_usb_hid.run | 3 +- repos/ports/run/vim.run | 4 +- repos/ports/run/virtualbox.run | 4 +- repos/ports/run/virtualbox_auto.inc | 2 +- repos/ports/src/app/seoul/component.cc | 11 +- repos/ports/src/app/seoul/console.cc | 41 ++++--- repos/ports/src/app/seoul/console.h | 6 +- repos/ports/src/virtualbox5/frontend/fb.h | 59 +++++----- repos/ports/src/virtualbox5/nova/target.mk | 1 + repos/ports/src/virtualbox5/target.mk | 1 + 112 files changed, 500 insertions(+), 696 deletions(-) create mode 100644 repos/os/src/drivers/framebuffer/spec/rpi/README diff --git a/repos/dde_linux/recipes/src/imx8_fb_drv/used_apis b/repos/dde_linux/recipes/src/imx8_fb_drv/used_apis index 761378a5f8..da546f3ebf 100644 --- a/repos/dde_linux/recipes/src/imx8_fb_drv/used_apis +++ b/repos/dde_linux/recipes/src/imx8_fb_drv/used_apis @@ -1,5 +1,6 @@ base os +blit platform_session timer_session report_session diff --git a/repos/dde_linux/src/drivers/framebuffer/imx8/include/component.h b/repos/dde_linux/src/drivers/framebuffer/imx8/include/component.h index e7e88289b9..2b915a7fba 100644 --- a/repos/dde_linux/src/drivers/framebuffer/imx8/include/component.h +++ b/repos/dde_linux/src/drivers/framebuffer/imx8/include/component.h @@ -27,9 +27,8 @@ #include #include #include -#include #include -#include +#include #include @@ -158,13 +157,13 @@ class Framebuffer::Session_component : public Genode::Rpc_object Genode::Dataspace_capability dataspace() override { _ds.realloc(&_ram, _driver.width() * _driver.height() * - Mode::bytes_per_pixel(Mode::RGB565)); + mode().bytes_per_pixel()); _in_mode_change = false; return _ds.cap(); } Mode mode() const override { - return Mode(_driver.width(), _driver.height(), Mode::RGB565); } + return Mode { .area = { _driver.width(), _driver.height() } }; } void mode_sigh(Genode::Signal_context_capability sigh) override { _mode_sigh = sigh; } @@ -179,12 +178,13 @@ class Framebuffer::Session_component : public Genode::Rpc_object { using namespace Genode; - if (!_driver.fb_addr() || - !_ds.local_addr() || - _in_mode_change) return; + if (!_driver.fb_addr() || !_ds.local_addr() || _in_mode_change) + return; - int width = _driver.width(); - int height = _driver.height(); + int width = _driver.width(); + int height = _driver.height(); + unsigned bpp = 4; + unsigned pitch = _driver.width(); /* clip specified coordinates against screen boundaries */ int x2 = min(x + w - 1, width - 1), @@ -194,18 +194,11 @@ class Framebuffer::Session_component : public Genode::Rpc_object if (x1 > x2 || y1 > y2) return; /* copy pixels from back buffer to physical frame buffer */ - Genode::Pixel_rgb565 * src = _ds.local_addr(); - Genode::Pixel_rgb888 * dst = (Genode::Pixel_rgb888*)_driver.fb_addr(); + char *src = _ds.local_addr() + bpp*(width*y1 + x1), + *dst = (char*)_driver.fb_addr() + bpp*(pitch*y1 + x1); - for (int row = y1; row <= y2; row++) { - int line_offset = width * row; - Genode::Pixel_rgb565 const * s = src + line_offset + x1; - Genode::Pixel_rgb888 * d = dst + line_offset + x1; - for (int col = x1; col <= x2; col++) { - Genode::Pixel_rgb565 const px = *s++; - *d++ = Genode::Pixel_rgb888(px.r(), px.g(), px.b(), px.a()); - } - } + blit(src, bpp*width, dst, bpp*pitch, + bpp*(x2 - x1 + 1), y2 - y1 + 1); } }; diff --git a/repos/dde_linux/src/drivers/framebuffer/imx8/target.mk b/repos/dde_linux/src/drivers/framebuffer/imx8/target.mk index c4419b3de3..4a11df4787 100644 --- a/repos/dde_linux/src/drivers/framebuffer/imx8/target.mk +++ b/repos/dde_linux/src/drivers/framebuffer/imx8/target.mk @@ -1,7 +1,7 @@ REQUIRES = arm_v8a TARGET = imx8_fb_drv -LIBS = base imx8_fb_include lx_kit_setjmp imx8_fb_drv +LIBS = base imx8_fb_include lx_kit_setjmp imx8_fb_drv blit SRC_CC = main.cc platform.cc lx_emul.cc SRC_C = dummies.c lx_emul_c.c diff --git a/repos/dde_linux/src/drivers/framebuffer/intel/include/component.h b/repos/dde_linux/src/drivers/framebuffer/intel/include/component.h index 58254da2b6..dfa47e2a5c 100644 --- a/repos/dde_linux/src/drivers/framebuffer/intel/include/component.h +++ b/repos/dde_linux/src/drivers/framebuffer/intel/include/component.h @@ -43,8 +43,13 @@ class Framebuffer::Driver struct Configuration { - struct lx_c_fb_config _lx = { 16, 64, 64, 2, - nullptr, 0, nullptr }; + struct lx_c_fb_config _lx = { .height = 16, + .width = 64, + .pitch = 64, + .bpp = 4, + .addr = nullptr, + .size = 0, + .lx_fb = nullptr }; } _config; Session_component &_session; @@ -168,8 +173,10 @@ class Framebuffer::Session_component : public Genode::Rpc_object return _ds.cap(); } - Mode mode() const override { - return Mode(_driver.width(), _driver.height(), Mode::RGB565); } + Mode mode() const override + { + return Mode { .area { _driver.width(), _driver.height() } }; + } void mode_sigh(Genode::Signal_context_capability sigh) override { _mode_sigh = sigh; } diff --git a/repos/dde_linux/src/drivers/framebuffer/intel/lx_emul_c.c b/repos/dde_linux/src/drivers/framebuffer/intel/lx_emul_c.c index e6f0d9f1ee..417fe87b40 100644 --- a/repos/dde_linux/src/drivers/framebuffer/intel/lx_emul_c.c +++ b/repos/dde_linux/src/drivers/framebuffer/intel/lx_emul_c.c @@ -47,7 +47,7 @@ void lx_c_allocate_framebuffer(struct drm_device * dev, if (!r) goto err2; r->width = c->width; r->height = c->height; - r->pixel_format = DRM_FORMAT_RGB565; + r->pixel_format = DRM_FORMAT_XRGB8888; r->pitches[0] = c->pitch; c->lx_fb = intel_framebuffer_create(obj, r); if (IS_ERR(c->lx_fb)) goto err2; diff --git a/repos/demo/include/scout/canvas.h b/repos/demo/include/scout/canvas.h index fadf975bb0..d7525ebd77 100644 --- a/repos/demo/include/scout/canvas.h +++ b/repos/demo/include/scout/canvas.h @@ -71,7 +71,7 @@ struct Scout::Canvas_base : Texture_allocator }; -#include +#include #include diff --git a/repos/demo/include/scout/graphics_backend_impl.h b/repos/demo/include/scout/graphics_backend_impl.h index 635cac0e33..c0a9d5c97c 100644 --- a/repos/demo/include/scout/graphics_backend_impl.h +++ b/repos/demo/include/scout/graphics_backend_impl.h @@ -16,7 +16,7 @@ /* Genode includes */ #include -#include +#include #include /* Scout includes */ @@ -24,7 +24,7 @@ namespace Scout { - using Genode::Pixel_rgb565; + using Genode::Pixel_rgb888; class Graphics_backend_impl; } @@ -45,8 +45,10 @@ class Scout::Graphics_backend_impl : public Graphics_backend Genode::Dataspace_capability _init_fb_ds(Area max_size) { - _gui.buffer(Framebuffer::Mode(max_size.w(), max_size.h()*2, - Framebuffer::Mode::RGB565), false); + Framebuffer::Mode const mode { .area = { max_size.w(), max_size.h()*2 }}; + + _gui.buffer(mode, false); + return _gui.framebuffer()->dataspace(); } @@ -111,7 +113,7 @@ class Scout::Graphics_backend_impl : public Graphics_backend { bring_to_front(); - typedef Genode::Pixel_rgb565 PT; + typedef Genode::Pixel_rgb888 PT; static Canvas canvas_0(_base(0), max_size, alloc); static Canvas canvas_1(_base(1), max_size, alloc); @@ -130,7 +132,7 @@ class Scout::Graphics_backend_impl : public Graphics_backend void copy_back_to_front(Rect rect) override { - typedef Genode::Pixel_rgb565 PT; + typedef Genode::Pixel_rgb888 PT; PT const *src = _base( _back_idx()); PT *dst = _base(_front_idx()); diff --git a/repos/demo/src/app/launchpad/launchpad_window.cc b/repos/demo/src/app/launchpad/launchpad_window.cc index 1a5658e08b..f9d4b810bd 100644 --- a/repos/demo/src/app/launchpad/launchpad_window.cc +++ b/repos/demo/src/app/launchpad/launchpad_window.cc @@ -175,4 +175,4 @@ void Launchpad_window::handle_scroll(int view_pos) ypos_sb(-view_pos, 0); } -template class Launchpad_window; +template class Launchpad_window; diff --git a/repos/demo/src/app/launchpad/main.cc b/repos/demo/src/app/launchpad/main.cc index f5f3de319c..e99a76ff99 100644 --- a/repos/demo/src/app/launchpad/main.cc +++ b/repos/demo/src/app/launchpad/main.cc @@ -105,7 +105,7 @@ struct Main : Scout::Event_handler _graphics_backend { _env.rm(), _gui, _heap, _max_size, _initial_position, _initial_size }; - Launchpad_window + Launchpad_window _launchpad { _env, _graphics_backend, _initial_position, _initial_size, _max_size, _env.pd().avail_ram().value }; diff --git a/repos/demo/src/app/scout/browser_window.cc b/repos/demo/src/app/scout/browser_window.cc index 6712e2183a..a00cbeee51 100644 --- a/repos/demo/src/app/scout/browser_window.cc +++ b/repos/demo/src/app/scout/browser_window.cc @@ -477,4 +477,4 @@ void Browser_window::handle_scroll(int view_pos) ypos_sb(-view_pos, 0); } -template class Browser_window; +template class Browser_window; diff --git a/repos/demo/src/app/scout/doc.cc b/repos/demo/src/app/scout/doc.cc index 7d5c481eb5..3ef5c76d4d 100644 --- a/repos/demo/src/app/scout/doc.cc +++ b/repos/demo/src/app/scout/doc.cc @@ -149,7 +149,7 @@ Document *create_document() b0->append_plaintext("that can be started by clicking on the application's name. Before starting an", &plain_style); b0->append_plaintext("application, the user can define the amount of memory quota to donate to the", &plain_style); b0->append_plaintext("new application by adjusting the red bar using the mouse.", &plain_style); - Launcher *l0 = new Launcher("launchpad", 1, 100000, 22*1024*1024); + Launcher *l0 = new Launcher("launchpad", 1, 100000, 36*1024*1024); b0->append_launchertext("Start the launchpad by clicking on this link...", &link_style, l0); chapter->append(b0); diff --git a/repos/demo/src/app/scout/main.cc b/repos/demo/src/app/scout/main.cc index 26f5b347b6..0e4d6c8f0a 100644 --- a/repos/demo/src/app/scout/main.cc +++ b/repos/demo/src/app/scout/main.cc @@ -82,7 +82,7 @@ struct Scout::Main : Scout::Event_handler void _init_navicons() { for (unsigned int i = 0; i < sizeof(navicons)/sizeof(void *); i++) { - Fade_icon *icon = new Fade_icon; + Fade_icon *icon = new Fade_icon; icon->rgba(navicons_rgba[i]); icon->alpha(100); *navicons[i] = icon; @@ -94,12 +94,12 @@ struct Scout::Main : Scout::Event_handler Document &_doc = *create_document(); /* create instance of browser window */ - Browser_window _browser { &_doc, _graphics_backend, + Browser_window _browser { &_doc, _graphics_backend, _initial_position, _initial_size, _max_size, _config }; /* initialize mouse cursor */ - Icon _mcursor { }; + Icon _mcursor { }; void _init_mouse_cursor() { diff --git a/repos/demo/src/app/scout/png_image.cc b/repos/demo/src/app/scout/png_image.cc index 0040c52cbf..bb7fdd7c4d 100644 --- a/repos/demo/src/app/scout/png_image.cc +++ b/repos/demo/src/app/scout/png_image.cc @@ -131,6 +131,7 @@ void Png_image::fill_cache(Canvas_base &canvas) row_ptr = (png_byte *)alloc().alloc(needed_row_size); curr_row_size = needed_row_size; } + memset(row_ptr, 0, curr_row_size); /* fill texture */ for (unsigned j = 0; j < _min_size.h(); j++) { diff --git a/repos/demo/src/app/scout/scrollbar.cc b/repos/demo/src/app/scout/scrollbar.cc index cb94bad48a..1562d47594 100644 --- a/repos/demo/src/app/scout/scrollbar.cc +++ b/repos/demo/src/app/scout/scrollbar.cc @@ -327,4 +327,4 @@ Element *Scrollbar::find(Point position) } -template class Scrollbar; +template class Scrollbar; diff --git a/repos/demo/src/app/scout/widgets.cc b/repos/demo/src/app/scout/widgets.cc index 12e29f3804..5aafc73931 100644 --- a/repos/demo/src/app/scout/widgets.cc +++ b/repos/demo/src/app/scout/widgets.cc @@ -198,8 +198,8 @@ Element *Icon::find(Point position) return 0; } -template class Horizontal_shadow; -template class Horizontal_shadow; -template class Icon; -template class Icon; -template class Icon; +template class Horizontal_shadow; +template class Horizontal_shadow; +template class Icon; +template class Icon; +template class Icon; diff --git a/repos/demo/src/server/liquid_framebuffer/main.cc b/repos/demo/src/server/liquid_framebuffer/main.cc index 2d9e0b1d36..0819b8e1a5 100644 --- a/repos/demo/src/server/liquid_framebuffer/main.cc +++ b/repos/demo/src/server/liquid_framebuffer/main.cc @@ -35,7 +35,7 @@ class Background_animator : public Scout::Tick { private: - Framebuffer_window &_fb_win; + Framebuffer_window &_fb_win; int _bg_offset = 0; @@ -44,7 +44,7 @@ class Background_animator : public Scout::Tick /** * Constructor */ - Background_animator(Framebuffer_window &fb_win) + Background_animator(Framebuffer_window &fb_win) : _fb_win(fb_win) { schedule(20); } /** @@ -169,7 +169,7 @@ class Liquid_fb::Main : public Scout::Event_handler (init_window_content(_env.ram(), _env.rm(), _heap, _input_session_component, config_fb_width, config_fb_height, config_alpha), true); - Framebuffer_window + Framebuffer_window _fb_win { _graphics_backend, window_content(), _initial_position, _initial_size, _max_size, config_title.string(), config_alpha, diff --git a/repos/demo/src/server/liquid_framebuffer/services.cc b/repos/demo/src/server/liquid_framebuffer/services.cc index 15f782675a..7a77a12638 100644 --- a/repos/demo/src/server/liquid_framebuffer/services.cc +++ b/repos/demo/src/server/liquid_framebuffer/services.cc @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -26,7 +26,7 @@ #include "services.h" -typedef Genode::Texture Texture_rgb565; +typedef Genode::Texture Texture_rgb888; class Window_content : public Scout::Element @@ -81,17 +81,17 @@ class Window_content : public Scout::Element Genode::Allocator &alloc; unsigned w, h; Genode::Attached_ram_dataspace ds; - Genode::Pixel_rgb565 *pixel; + Genode::Pixel_rgb888 *pixel; unsigned char *alpha; - Genode::Texture texture; + Genode::Texture texture; Fb_texture(Genode::Ram_allocator &ram, Genode::Region_map &local_rm, Genode::Allocator &alloc, unsigned w, unsigned h, bool config_alpha) : alloc(alloc), w(w), h(h), - ds(ram, local_rm, w*h*sizeof(Genode::Pixel_rgb565)), - pixel(ds.local_addr()), + ds(ram, local_rm, w*h*sizeof(Genode::Pixel_rgb888)), + pixel(ds.local_addr()), alpha((unsigned char *)alloc.alloc(w*h)), texture(pixel, alpha, Scout::Area(w, h)) { @@ -250,8 +250,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object Mode mode() const override { - return Mode(_window_content.mode_size().w(), - _window_content.mode_size().h(), Mode::RGB565); + return Mode { .area = _window_content.mode_size() }; } void mode_sigh(Genode::Signal_context_capability sigh) override { diff --git a/repos/demo/src/server/nitlog/main.cc b/repos/demo/src/server/nitlog/main.cc index c91932c04e..58bcd0fc56 100644 --- a/repos/demo/src/server/nitlog/main.cc +++ b/repos/demo/src/server/nitlog/main.cc @@ -21,7 +21,7 @@ #include #include #include -#include +#include /* * Nitpicker's graphics backend @@ -409,8 +409,7 @@ struct Nitlog::Main void _init_gui_buffer() { - _gui.buffer(Framebuffer::Mode(_win_w, _win_h, - Framebuffer::Mode::RGB565), false); + _gui.buffer(Framebuffer::Mode { .area = { _win_w, _win_h } }, false); } bool const _gui_buffer_initialized = (_init_gui_buffer(), true); @@ -420,7 +419,7 @@ struct Nitlog::Main /* create log window */ Attached_dataspace _fb_ds { _env.rm(), _gui.framebuffer()->dataspace() }; - Canvas _canvas { _fb_ds.local_addr(), + Canvas _canvas { _fb_ds.local_addr(), ::Area(_win_w, _win_h) }; Log_window _log_window { _canvas, _font }; diff --git a/repos/gems/include/gems/gui_buffer.h b/repos/gems/include/gems/gui_buffer.h index a3442e7d48..4be377e71c 100644 --- a/repos/gems/include/gems/gui_buffer.h +++ b/repos/gems/include/gems/gui_buffer.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -31,7 +30,6 @@ struct Gui_buffer { typedef Genode::Pixel_rgb888 Pixel_rgb888; - typedef Genode::Pixel_rgb565 Pixel_rgb565; typedef Genode::Pixel_alpha8 Pixel_alpha8; typedef Genode::Surface Pixel_surface; @@ -58,11 +56,6 @@ struct Gui_buffer /* setup virtual framebuffer mode */ gui.buffer(mode, true); - if (mode.format() != Framebuffer::Mode::RGB565) { - Genode::warning("color mode ", mode, " not supported"); - return Genode::Dataspace_capability(); - } - return gui.framebuffer()->dataspace(); } @@ -88,8 +81,8 @@ struct Gui_buffer Genode::Ram_allocator &ram, Genode::Region_map &rm) : ram(ram), rm(rm), gui(gui), - mode(Genode::max(1UL, size.w()), Genode::max(1UL, size.h()), - gui.mode().format()) + mode({ .area = { Genode::max(1U, size.w()), + Genode::max(1U, size.h()) } }) { reset_surface(); } @@ -97,7 +90,7 @@ struct Gui_buffer /** * Return size of virtual framebuffer */ - Area size() const { return Area(mode.width(), mode.height()); } + Area size() const { return mode.area; } template void apply_to_surface(FN const &fn) @@ -175,7 +168,7 @@ struct Gui_buffer // XXX track dirty rectangles Rect const clip_rect(Genode::Surface_base::Point(0, 0), size()); - Pixel_rgb565 *pixel_base = fb_ds.local_addr(); + Pixel_rgb888 *pixel_base = fb_ds.local_addr(); Pixel_alpha8 *alpha_base = fb_ds.local_addr() + mode.bytes_per_pixel()*size().count(); diff --git a/repos/gems/include/nano3d/scene.h b/repos/gems/include/nano3d/scene.h index 123222d346..61a0d703e1 100644 --- a/repos/gems/include/nano3d/scene.h +++ b/repos/gems/include/nano3d/scene.h @@ -81,12 +81,6 @@ class Nano3d::Scene _init_framebuffer(Gui::Connection &gui, Gui::Area const size) { - Framebuffer::Mode::Format const format = gui.mode().format(); - if (format != Framebuffer::Mode::RGB565) { - Genode::error("framebuffer mode ", (int)format, " is not supported"); - throw Unsupported_color_depth(); - } - /* * Dimension the virtual framebuffer 3 times as high as the * visible view because it contains the visible buffer, the @@ -94,7 +88,7 @@ class Nano3d::Scene */ bool const use_alpha = true; unsigned const height = size.h()*NUM_BUFFERS; - gui.buffer(Framebuffer::Mode(size.w(), height, format), + gui.buffer(Framebuffer::Mode { .area = { size.w(), height } }, use_alpha); return *gui.framebuffer(); @@ -109,7 +103,7 @@ class Nano3d::Scene */ Gui::Area size() const { - return Gui::Area(mode.width(), mode.height()/NUM_BUFFERS); + return Gui::Area(mode.area.w(), mode.area.h()/NUM_BUFFERS); } Genode::Attached_dataspace ds { rm, framebuffer.dataspace() }; diff --git a/repos/gems/run/cpu_load_display.run b/repos/gems/run/cpu_load_display.run index 70243c74db..cfb9a166fe 100644 --- a/repos/gems/run/cpu_load_display.run +++ b/repos/gems/run/cpu_load_display.run @@ -32,8 +32,8 @@ install_config { - - + + diff --git a/repos/gems/run/decorator.run b/repos/gems/run/decorator.run index 6f9deaf856..61963ad91b 100644 --- a/repos/gems/run/decorator.run +++ b/repos/gems/run/decorator.run @@ -34,8 +34,8 @@ install_config { - - + + diff --git a/repos/gems/run/decorator_stress.run b/repos/gems/run/decorator_stress.run index 5a7c76857b..3766c9b94b 100644 --- a/repos/gems/run/decorator_stress.run +++ b/repos/gems/run/decorator_stress.run @@ -36,8 +36,8 @@ install_config { - - + + diff --git a/repos/gems/run/depot_deploy.run b/repos/gems/run/depot_deploy.run index f345681120..c6c1000820 100644 --- a/repos/gems/run/depot_deploy.run +++ b/repos/gems/run/depot_deploy.run @@ -45,8 +45,8 @@ install_config { - - + + diff --git a/repos/gems/run/gui_fader.run b/repos/gems/run/gui_fader.run index d98e74d828..4121ce88d3 100644 --- a/repos/gems/run/gui_fader.run +++ b/repos/gems/run/gui_fader.run @@ -31,8 +31,8 @@ install_config { - - + + @@ -91,7 +91,7 @@ install_config { - + @@ -103,7 +103,7 @@ install_config { - + @@ -112,7 +112,7 @@ install_config { - + diff --git a/repos/gems/run/leitzentrale.run b/repos/gems/run/leitzentrale.run index ffe0978604..7c2a48014f 100644 --- a/repos/gems/run/leitzentrale.run +++ b/repos/gems/run/leitzentrale.run @@ -65,8 +65,8 @@ install_config { - - + + diff --git a/repos/gems/run/menu_view.run b/repos/gems/run/menu_view.run index e54b449de7..dad398b284 100644 --- a/repos/gems/run/menu_view.run +++ b/repos/gems/run/menu_view.run @@ -35,8 +35,8 @@ install_config { - - + + diff --git a/repos/gems/run/nano3d.run b/repos/gems/run/nano3d.run index 7224538b3a..7ec6f7e4e1 100644 --- a/repos/gems/run/nano3d.run +++ b/repos/gems/run/nano3d.run @@ -26,8 +26,8 @@ append config { - - + + diff --git a/repos/gems/run/terminal_echo.run b/repos/gems/run/terminal_echo.run index d1d953376a..8774aa64dd 100644 --- a/repos/gems/run/terminal_echo.run +++ b/repos/gems/run/terminal_echo.run @@ -29,8 +29,8 @@ install_config { - - + + diff --git a/repos/gems/run/terminal_log.run b/repos/gems/run/terminal_log.run index c40de75680..c2e117542d 100644 --- a/repos/gems/run/terminal_log.run +++ b/repos/gems/run/terminal_log.run @@ -35,8 +35,8 @@ install_config { - - + + diff --git a/repos/gems/run/text_area.run b/repos/gems/run/text_area.run index e0ac86fc7c..e800f503dd 100644 --- a/repos/gems/run/text_area.run +++ b/repos/gems/run/text_area.run @@ -35,8 +35,8 @@ install_config { - - + + diff --git a/repos/gems/run/text_painter.run b/repos/gems/run/text_painter.run index 82bc00c8f2..c4e5dd49a6 100644 --- a/repos/gems/run/text_painter.run +++ b/repos/gems/run/text_painter.run @@ -31,8 +31,8 @@ install_config { - - + + diff --git a/repos/gems/run/wm.run b/repos/gems/run/wm.run index 79fb9bc9ba..8a7aeba543 100644 --- a/repos/gems/run/wm.run +++ b/repos/gems/run/wm.run @@ -38,8 +38,8 @@ install_config { - - + + diff --git a/repos/gems/src/app/backdrop/main.cc b/repos/gems/src/app/backdrop/main.cc index dbb80d52e4..126f2b8b1f 100644 --- a/repos/gems/src/app/backdrop/main.cc +++ b/repos/gems/src/app/backdrop/main.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include /* gems includes */ @@ -63,11 +62,6 @@ struct Backdrop::Main /* setup virtual framebuffer mode */ gui.buffer(mode, false); - if (mode.format() != Framebuffer::Mode::RGB565) { - Genode::warning("Color mode %d not supported\n", (int)mode.format()); - return Dataspace_capability(); - } - return gui.framebuffer()->dataspace(); } @@ -92,10 +86,7 @@ struct Backdrop::Main /** * Return size of virtual framebuffer */ - Surface_base::Area size() const - { - return Surface_base::Area(mode.width(), mode.height()); - } + Surface_base::Area size() const { return mode.area; } /** * Return back buffer as painting surface @@ -251,13 +242,12 @@ void Backdrop::Main::_apply_image(Xml_node operation) Png_image png_image(_env.ram(), _env.rm(), _heap, file.data()); Area const scaled_size = calc_scaled_size(operation, png_image.size(), - Area(_buffer->mode.width(), - _buffer->mode.height())); + _buffer->mode.area); /* * Determine parameters of graphics operation */ - int const h_gap = (int)_buffer->mode.width() - scaled_size.w(), - v_gap = (int)_buffer->mode.height() - scaled_size.h(); + int const h_gap = (int)_buffer->mode.area.w() - scaled_size.w(), + v_gap = (int)_buffer->mode.area.h() - scaled_size.h(); int const anchored_xpos = anchor.horizontal == Anchor::LOW ? 0 : anchor.horizontal == Anchor::CENTER ? h_gap/2 @@ -291,7 +281,7 @@ void Backdrop::Main::_apply_image(Xml_node operation) */ /* create texture with down-sampled scaled image */ - typedef Pixel_rgb565 PT; + typedef Pixel_rgb888 PT; Chunky_texture texture(_env.ram(), _env.rm(), scaled_size); convert_pixel_format(scaled_texture, texture, alpha, _heap); @@ -309,7 +299,7 @@ void Backdrop::Main::_apply_fill(Xml_node operation) */ /* create texture with down-sampled scaled image */ - typedef Pixel_rgb565 PT; + typedef Pixel_rgb888 PT; Color const color = operation.attribute_value("color", Color(0, 0, 0)); @@ -326,9 +316,8 @@ void Backdrop::Main::_handle_config() Framebuffer::Mode const phys_mode = _gui.mode(); Framebuffer::Mode const - mode(_config.xml().attribute_value("width", (unsigned)phys_mode.width()), - _config.xml().attribute_value("height", (unsigned)phys_mode.height()), - phys_mode.format()); + mode { .area = { _config.xml().attribute_value("width", phys_mode.area.w()), + _config.xml().attribute_value("height", phys_mode.area.h()) } }; _buffer.construct(_env, _gui, mode); diff --git a/repos/gems/src/app/cpu_load_display/main.cc b/repos/gems/src/app/cpu_load_display/main.cc index 2f7525c61f..a9ca2fe7e5 100644 --- a/repos/gems/src/app/cpu_load_display/main.cc +++ b/repos/gems/src/app/cpu_load_display/main.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -469,7 +469,7 @@ void Component::construct(Genode::Env &env) { enum { UPDATE_RATE_MS = 250 }; - static Cpu_load_display::Scene + static Cpu_load_display::Scene scene(env, UPDATE_RATE_MS, Gui::Point(0, 0), Gui::Area(400, 400)); } diff --git a/repos/gems/src/app/decorator/main.cc b/repos/gems/src/app/decorator/main.cc index dd649bb5d2..1b3a2e1651 100644 --- a/repos/gems/src/app/decorator/main.cc +++ b/repos/gems/src/app/decorator/main.cc @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include /* decorator includes */ @@ -45,16 +45,14 @@ struct Decorator::Main : Window_factory_base { Framebuffer::Mode const mode; Attached_dataspace fb_ds; - Decorator::Canvas canvas; + Decorator::Canvas canvas; Canvas(Env &env, Gui::Connection &nitpicker) : mode(nitpicker.mode()), fb_ds(env.rm(), (nitpicker.buffer(mode, false), nitpicker.framebuffer()->dataspace())), - canvas(fb_ds.local_addr(), - Area(mode.width(), mode.height()), - env.ram(), env.rm()) + canvas(fb_ds.local_addr(), mode.area, env.ram(), env.rm()) { } }; @@ -66,9 +64,7 @@ struct Decorator::Main : Window_factory_base { _canvas.construct(_env, _nitpicker); - _window_stack.mark_as_dirty(Rect(Point(0, 0), - Area(_canvas->mode.width(), - _canvas->mode.height()))); + _window_stack.mark_as_dirty(Rect(Point(0, 0), _canvas->mode.area)); Dirty_rect dirty = _window_stack.draw(_canvas->canvas); diff --git a/repos/gems/src/app/decorator/texture_by_id.cc b/repos/gems/src/app/decorator/texture_by_id.cc index 66a644f22c..9f56f1f867 100644 --- a/repos/gems/src/app/decorator/texture_by_id.cc +++ b/repos/gems/src/app/decorator/texture_by_id.cc @@ -14,8 +14,8 @@ /* Genode includes */ #include #include -#include -#include +#include +#include /* local includes */ #include "canvas.h" @@ -62,7 +62,7 @@ extern unsigned char _binary_windowed_rgba_start[]; Texture_base const & Decorator::texture_by_id(Texture_id id, Ram_allocator &ram, Region_map &rm) { - static Icon_texture const icons[4] { + static Icon_texture const icons[4] { { ram, rm, _binary_closer_rgba_start }, { ram, rm, _binary_minimize_rgba_start }, { ram, rm, _binary_maximize_rgba_start }, diff --git a/repos/gems/src/app/menu_view/types.h b/repos/gems/src/app/menu_view/types.h index 9011d8282e..15860c2af4 100644 --- a/repos/gems/src/app/menu_view/types.h +++ b/repos/gems/src/app/menu_view/types.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/repos/gems/src/app/nano3d/main.cc b/repos/gems/src/app/nano3d/main.cc index bd9f11fd6a..3ce911e6db 100644 --- a/repos/gems/src/app/nano3d/main.cc +++ b/repos/gems/src/app/nano3d/main.cc @@ -16,8 +16,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -229,7 +229,7 @@ void Component::construct(Genode::Env &env) { enum { UPDATE_RATE_MS = 20 }; - static Scene + static Scene scene(env, UPDATE_RATE_MS, Gui::Point(-200, -200), Gui::Area(400, 400)); } diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index b2a2ae4df9..99eef462ea 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -1162,11 +1162,11 @@ void Sculpt::Main::_handle_window_layout() Framebuffer::Mode const mode = _gui->mode(); /* area reserved for the panel */ - Rect const panel(Point(0, 0), Area(mode.width(), panel_height)); + Rect const panel(Point(0, 0), Area(mode.area.w(), panel_height)); /* available space on the right of the menu */ Rect avail(Point(0, panel.h()), - Point(mode.width() - 1, mode.height() - 1)); + Point(mode.area.w() - 1, mode.area.h() - 1)); Point const log_offset = _log_visible ? Point(0, 0) @@ -1174,8 +1174,8 @@ void Sculpt::Main::_handle_window_layout() Point const log_p1(avail.x2() - log_min_w - margins.right + 1 + log_offset.x(), avail.y1() + margins.top); - Point const log_p2(mode.width() - margins.right - 1 + log_offset.x(), - mode.height() - margins.bottom - 1); + Point const log_p2(mode.area.w() - margins.right - 1 + log_offset.x(), + mode.area.h() - margins.bottom - 1); /* position of the inspect window */ Point const inspect_p1(avail.x1() + margins.left, avail.y1() + margins.top); @@ -1225,7 +1225,7 @@ void Sculpt::Main::_handle_window_layout() Area const size = win_size(win); Point const pos = _network_visible ? Point(log_p1.x() - size.w(), avail.y1()) - : Point(mode.width(), avail.y1()); + : Point(mode.area.w(), avail.y1()); gen_window(win, Rect(pos, size)); }); @@ -1301,7 +1301,7 @@ void Sculpt::Main::_handle_window_layout() _with_window(window_list, logo_label, [&] (Xml_node win) { Area const size = win_size(win); - Point const pos(mode.width() - size.w(), mode.height() - size.h()); + Point const pos(mode.area.w() - size.w(), mode.area.h() - size.h()); gen_window(win, Rect(pos, size)); }); }); @@ -1334,12 +1334,12 @@ void Sculpt::Main::_handle_gui_mode() if (!_fonts_config.try_generate_manually_managed()) { - _font_size_px = (float)mode.height() / 60.0; + _font_size_px = (float)mode.area.h() / 60.0; if (_font_size == Font_size::SMALL) _font_size_px *= 0.85; if (_font_size == Font_size::LARGE) _font_size_px *= 1.35; - Area const size(mode.width(), mode.height()); + Area const size(mode.area.w(), mode.area.h()); _screen_size = size; _panel_menu_view.min_width = size.w(); unsigned const menu_width = max(_font_size_px*21, 320.0); diff --git a/repos/gems/src/app/themed_decorator/theme.h b/repos/gems/src/app/themed_decorator/theme.h index f50c59270e..8ce032730b 100644 --- a/repos/gems/src/app/themed_decorator/theme.h +++ b/repos/gems/src/app/themed_decorator/theme.h @@ -16,7 +16,6 @@ /* Genode includes */ #include -#include #include #include @@ -25,7 +24,6 @@ namespace Decorator { class Theme; typedef Genode::Pixel_rgb888 Pixel_rgb888; - typedef Genode::Pixel_rgb565 Pixel_rgb565; typedef Genode::Pixel_alpha8 Pixel_alpha8; typedef Genode::Surface Pixel_surface; diff --git a/repos/gems/src/app/themed_decorator/window.h b/repos/gems/src/app/themed_decorator/window.h index 3f90942b1f..ba0fd04b39 100644 --- a/repos/gems/src/app/themed_decorator/window.h +++ b/repos/gems/src/app/themed_decorator/window.h @@ -324,9 +324,8 @@ class Decorator::Window : public Window_base, public Animator::Item || size_top_bottom.h() > _size_top_bottom.h() || !_buffer_top_bottom.constructed()) { - _gui_top_bottom.buffer(Framebuffer::Mode(size_top_bottom.w(), - size_top_bottom.h(), - Framebuffer::Mode::RGB565), + _gui_top_bottom.buffer(Framebuffer::Mode { .area = { size_top_bottom.w(), + size_top_bottom.h() } }, use_alpha); _buffer_top_bottom.construct(_gui_top_bottom, size_top_bottom, @@ -341,9 +340,8 @@ class Decorator::Window : public Window_base, public Animator::Item || size_left_right.h() > _size_left_right.h() || !_buffer_left_right.constructed()) { - _gui_left_right.buffer(Framebuffer::Mode(size_left_right.w(), - size_left_right.h(), - Framebuffer::Mode::RGB565), + _gui_left_right.buffer(Framebuffer::Mode { .area = { size_left_right.w(), + size_left_right.h() } }, use_alpha); _buffer_left_right.construct(_gui_left_right, size_left_right, diff --git a/repos/gems/src/app/window_layouter/main.cc b/repos/gems/src/app/window_layouter/main.cc index 119f5e5938..f908a7af51 100644 --- a/repos/gems/src/app/window_layouter/main.cc +++ b/repos/gems/src/app/window_layouter/main.cc @@ -329,7 +329,7 @@ struct Window_layouter::Main : Operations, /* determine maximized window geometry */ Framebuffer::Mode const mode = _gui.mode(); - _screen_size = Area(mode.width(), mode.height()); + _screen_size = mode.area; _update_window_layout(); } diff --git a/repos/gems/src/server/gui_fader/main.cc b/repos/gems/src/server/gui_fader/main.cc index ea84be2f50..ad85ab5a06 100644 --- a/repos/gems/src/server/gui_fader/main.cc +++ b/repos/gems/src/server/gui_fader/main.cc @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -50,7 +50,7 @@ namespace Gui_fader { using Genode::Reconstructible; using Genode::Constructible; - typedef Genode::Pixel_rgb565 Pixel_rgb565; + typedef Genode::Pixel_rgb888 Pixel_rgb888; typedef Genode::Pixel_alpha8 Pixel_alpha8; } @@ -62,7 +62,7 @@ class Gui_fader::Src_buffer { private: - typedef Pixel_rgb565 Pixel; + typedef Pixel_rgb888 Pixel; bool const _use_alpha; Attached_ram_dataspace _ds; @@ -103,11 +103,11 @@ class Gui_fader::Dst_buffer Genode::Attached_dataspace _ds; Area _size; - Surface _pixel_surface { _ds.local_addr(), _size }; + Surface _pixel_surface { _ds.local_addr(), _size }; Surface _alpha_surface { - _ds.local_addr() + _size.count()*sizeof(Pixel_rgb565), + _ds.local_addr() + _size.count()*sizeof(Pixel_rgb888), _size }; @@ -119,12 +119,12 @@ class Gui_fader::Dst_buffer { /* initialize input-mask buffer */ unsigned char *input_mask_buffer = _ds.local_addr() - + _size.count()*(1 + sizeof(Pixel_rgb565)); + + _size.count()*(1 + sizeof(Pixel_rgb888)); Genode::memset(input_mask_buffer, 0xff, _size.count()); } - Surface &pixel_surface() { return _pixel_surface; } + Surface &pixel_surface() { return _pixel_surface; } Surface &alpha_surface() { return _alpha_surface; } }; @@ -415,7 +415,7 @@ class Gui_fader::Gui_session_component void buffer(Framebuffer::Mode mode, bool use_alpha) override { - Area const size(mode.width(), mode.height()); + Area const size = mode.area; _src_buffer.construct(_env, size, use_alpha); diff --git a/repos/gems/src/server/terminal/framebuffer.h b/repos/gems/src/server/terminal/framebuffer.h index 20ef44570f..a9c2784893 100644 --- a/repos/gems/src/server/terminal/framebuffer.h +++ b/repos/gems/src/server/terminal/framebuffer.h @@ -28,7 +28,7 @@ class Terminal::Framebuffer Env &_env; - ::Framebuffer::Connection _fb { _env, ::Framebuffer::Mode() }; + ::Framebuffer::Connection _fb { _env, ::Framebuffer::Mode { } }; Constructible _ds { }; @@ -47,8 +47,8 @@ class Terminal::Framebuffer _fb.mode_sigh(mode_sigh); } - unsigned w() const { return _mode.width(); } - unsigned h() const { return _mode.height(); } + unsigned w() const { return _mode.area.w(); } + unsigned h() const { return _mode.area.h(); } template PT *pixel() { return _ds->local_addr(); } @@ -64,10 +64,7 @@ class Terminal::Framebuffer */ bool mode_changed() const { - ::Framebuffer::Mode _new_mode = _fb.mode(); - - return _new_mode.width() != _mode.width() - || _new_mode.height() != _mode.height(); + return _fb.mode().area != _mode.area; } void switch_to_new_mode() @@ -83,7 +80,7 @@ class Terminal::Framebuffer * the old (possibly too small) dataspace. */ _mode = _fb.mode(); - if (_mode.width() && _mode.height()) + if (_mode.area.count() > 0) _ds.construct(_env.rm(), _fb.dataspace()); } }; diff --git a/repos/gems/src/server/terminal/main.cc b/repos/gems/src/server/terminal/main.cc index c169d22c9a..e3f1ad6367 100644 --- a/repos/gems/src/server/terminal/main.cc +++ b/repos/gems/src/server/terminal/main.cc @@ -96,7 +96,7 @@ struct Terminal::Main : Character_consumer struct Paste_buffer { char buffer[READ_BUFFER_SIZE]; } _paste_buffer { }; - typedef Pixel_rgb565 PT; + typedef Pixel_rgb888 PT; Constructible> _text_screen_surface { }; diff --git a/repos/gems/src/server/terminal/text_screen_surface.h b/repos/gems/src/server/terminal/text_screen_surface.h index ac038323b3..c12a429b89 100644 --- a/repos/gems/src/server/terminal/text_screen_surface.h +++ b/repos/gems/src/server/terminal/text_screen_surface.h @@ -16,7 +16,7 @@ #define _TEXT_SCREEN_SURFACE_H_ /* Genode includes */ -#include +#include /* terminal includes */ #include diff --git a/repos/gems/src/server/wm/gui.h b/repos/gems/src/server/wm/gui.h index a341854b9f..fecb14f9f0 100644 --- a/repos/gems/src/server/wm/gui.h +++ b/repos/gems/src/server/wm/gui.h @@ -980,9 +980,7 @@ class Wm::Gui::Session_component : public Rpc_object, * mode */ if (_resize_requested) - return Framebuffer::Mode(_requested_size.w(), - _requested_size.h(), - real_mode.format()); + return Framebuffer::Mode { .area = _requested_size }; /* * If the first top-level view has a defined size, use it @@ -990,9 +988,7 @@ class Wm::Gui::Session_component : public Rpc_object, */ if (Top_level_view const *v = _top_level_views.first()) if (v->size().valid()) - return Framebuffer::Mode(v->size().w(), - v->size().h(), - real_mode.format()); + return Framebuffer::Mode { .area = v->size() }; /* * If top-level view has yet been defined, return the real mode. diff --git a/repos/gems/src/test/driver_manager/main.cc b/repos/gems/src/test/driver_manager/main.cc index 70de5f759b..b330f76b8f 100644 --- a/repos/gems/src/test/driver_manager/main.cc +++ b/repos/gems/src/test/driver_manager/main.cc @@ -123,7 +123,7 @@ struct Test::Main { if (_config.xml().has_sub_node("check_framebuffer")) { log("connect to framebuffer driver"); - Framebuffer::Mode mode(640, 480, Framebuffer::Mode::RGB565); + Framebuffer::Mode mode { .area = { 640, 480 } }; Framebuffer::Connection fb(_env, mode); } diff --git a/repos/gems/src/test/text_painter/main.cc b/repos/gems/src/test/text_painter/main.cc index 1a2326653d..856de2a57a 100644 --- a/repos/gems/src/test/text_painter/main.cc +++ b/repos/gems/src/test/text_painter/main.cc @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,14 +51,13 @@ struct Test::Main { Env &_env; - Framebuffer::Connection _fb { _env, Framebuffer::Mode() }; + Framebuffer::Connection _fb { _env, Framebuffer::Mode { } }; Attached_dataspace _fb_ds { _env.rm(), _fb.dataspace() }; - typedef Pixel_rgb565 PT; + typedef Pixel_rgb888 PT; - Surface_base::Area const _size { (unsigned)_fb.mode().width(), - (unsigned)_fb.mode().height() }; + Surface_base::Area const _size = _fb.mode().area; Surface _surface { _fb_ds.local_addr(), _size }; diff --git a/repos/libports/run/mesa.inc b/repos/libports/run/mesa.inc index d1434cd6b4..bf4c028179 100644 --- a/repos/libports/run/mesa.inc +++ b/repos/libports/run/mesa.inc @@ -48,8 +48,8 @@ set config { - - + + diff --git a/repos/libports/run/mupdf.run b/repos/libports/run/mupdf.run index 0ca7bbe07a..4f1085bbdb 100644 --- a/repos/libports/run/mupdf.run +++ b/repos/libports/run/mupdf.run @@ -34,8 +34,8 @@ set config { - - + + diff --git a/repos/libports/run/qt5_common.inc b/repos/libports/run/qt5_common.inc index 28df487ac1..9636cd07de 100644 --- a/repos/libports/run/qt5_common.inc +++ b/repos/libports/run/qt5_common.inc @@ -224,7 +224,7 @@ proc qt5_start_nodes { feature_arg } { - } [qt5_decorator_config] { + } [qt5_decorator_config] { diff --git a/repos/libports/run/qt5_drivers.inc b/repos/libports/run/qt5_drivers.inc index 5692dbe762..f1edd85e75 100644 --- a/repos/libports/run/qt5_drivers.inc +++ b/repos/libports/run/qt5_drivers.inc @@ -178,7 +178,7 @@ proc drivers_start_nodes { feature_arg } { append_if [use_fb_drv feature] start_nodes { - + } diff --git a/repos/libports/src/app/pdf_view/main.cc b/repos/libports/src/app/pdf_view/main.cc index 8f04c3e318..09a3b9a4aa 100644 --- a/repos/libports/src/app/pdf_view/main.cc +++ b/repos/libports/src/app/pdf_view/main.cc @@ -23,6 +23,7 @@ #include #include #include +#include /* MuPDF includes */ extern "C" { @@ -37,71 +38,19 @@ extern "C" { #include -/*************** - ** Dithering ** - ***************/ - -/* - * XXX blatantly copied from 'demo/src/app/backdrop/main.cc' - * - * We should factor-out the dithering support into a separate header file. - * But where is a good place to put it? - */ - -enum { DITHER_SIZE = 16, DITHER_MASK = DITHER_SIZE - 1 }; - -static const int dither_matrix[DITHER_SIZE][DITHER_SIZE] = { - { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, - { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, - { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, - { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, - { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, - { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, - { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, - { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, - { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, - { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, - { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, - { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, - { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, - { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, - { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, - { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } -}; +typedef Genode::Pixel_rgb888 pixel_t; -static inline uint16_t rgb565(int r, int g, int b) +static void copy_line_rgba(const unsigned char *rgba_src, + pixel_t *dst, int num_pixels) { - enum { - R_MASK = 0xf800, R_LSHIFT = 8, - G_MASK = 0x07e0, G_LSHIFT = 3, - B_MASK = 0x001f, B_RSHIFT = 3 - }; - return ((r << R_LSHIFT) & R_MASK) - | ((g << G_LSHIFT) & G_MASK) - | ((b >> B_RSHIFT) & B_MASK); -} - - -static void convert_line_rgba_to_rgb565(const unsigned char *rgba_src, - uint16_t *dst, int num_pixels, int line) -{ - using namespace Genode; - - enum { CHANNEL_MAX = 255 }; - - int const *dm = dither_matrix[line & DITHER_MASK]; - for (int i = 0; i < num_pixels; i++) { - int v = dm[i & DITHER_MASK] >> 5; + unsigned const r = *rgba_src++; + unsigned const g = *rgba_src++; + unsigned const b = *rgba_src++; + rgba_src++; /* ignore alpha */ - *dst++ = rgb565(min(v + (int)rgba_src[0], (int)CHANNEL_MAX), - min(v + (int)rgba_src[1], (int)CHANNEL_MAX), - min(v + (int)rgba_src[2], (int)CHANNEL_MAX)); - - /* we ignore the alpha channel */ - - rgba_src += 4; /* next pixel */ + *dst++ = pixel_t(r, g, b); } } @@ -130,7 +79,6 @@ class Pdf_view class Non_supported_framebuffer_mode { }; class Unexpected_document_color_depth { }; - typedef uint16_t pixel_t; typedef Framebuffer::Mode Mode; private: @@ -167,19 +115,19 @@ class Pdf_view _nit_mode = _gui.mode(); - int max_x = Genode::max(_nit_mode.width(), _fb_mode.width()); - int max_y = Genode::max(_nit_mode.height(), _fb_mode.height()); + unsigned max_x = Genode::max(_nit_mode.area.w(), _fb_mode.area.w()); + unsigned max_y = Genode::max(_nit_mode.area.h(), _fb_mode.area.h()); - if (max_x > _fb_mode.width() || max_y > _fb_mode.height()) { - _fb_mode = Mode(max_x, max_y, _nit_mode.format()); + if (max_x > _fb_mode.area.w() || max_y > _fb_mode.area.h()) { + _fb_mode = Mode { .area = { max_x, max_y } }; _gui.buffer(_fb_mode, NO_ALPHA); if (_fb_ds.constructed()) _fb_ds.destruct(); _fb_ds.construct(_env.rm(), _framebuffer.dataspace()); } - _pdfapp.scrw = _nit_mode.width(); - _pdfapp.scrh = _nit_mode.height(); + _pdfapp.scrw = _nit_mode.area.w(); + _pdfapp.scrh = _nit_mode.area.h(); /* * XXX replace heuristics with a meaningful computation @@ -187,12 +135,11 @@ class Pdf_view * The magic values are hand-tweaked manually to accommodating the * use case of showing slides. */ - _pdfapp.resolution = Genode::min(_nit_mode.width()/5, - _nit_mode.height()/3.8); + _pdfapp.resolution = Genode::min(_nit_mode.area.w()/5, + _nit_mode.area.h()/3.8); typedef Gui::Session::Command Command; - _gui.enqueue( - _view, Rect(Point(), Area(_nit_mode.width(), _nit_mode.height()))); + _gui.enqueue(_view, Rect(Point(), _nit_mode.area)); _gui.enqueue(_view, Gui::Session::View_handle()); _gui.execute(); } @@ -200,7 +147,7 @@ class Pdf_view void _handle_nit_mode() { _rebuffer(); - pdfapp_onresize(&_pdfapp, _nit_mode.width(), _nit_mode.height()); + pdfapp_onresize(&_pdfapp, _nit_mode.area.w(), _nit_mode.area.h()); } pdfapp_t _pdfapp { }; @@ -268,7 +215,7 @@ class Pdf_view void _refresh() { - _framebuffer.refresh(0, 0, _nit_mode.width(), _nit_mode.height()); + _framebuffer.refresh(0, 0, _nit_mode.area.w(), _nit_mode.area.h()); /* handle one sync signal only */ _framebuffer.sync_sigh(Genode::Signal_context_capability()); @@ -335,12 +282,12 @@ class Pdf_view void Pdf_view::show() { - Genode::Area<> const fb_size(_fb_mode.width(), _fb_mode.height()); + Framebuffer::Area const fb_size = _fb_mode.area; int const x_max = Genode::min((int)fb_size.w(), _pdfapp.image->w); int const y_max = Genode::min((int)fb_size.h(), _pdfapp.image->h); /* clear framebuffer */ - memset(_fb_base(), 0, _fb_ds->size()); + ::memset((void *)_fb_base(), 0, _fb_ds->size()); Genode::size_t src_line_bytes = _pdfapp.image->n * _pdfapp.image->w; unsigned char *src_line = _pdfapp.image->samples; @@ -354,15 +301,15 @@ void Pdf_view::show() int const tweaked_y_max = y_max - 2; /* center vertically if the dst buffer is higher than the image */ - if (_pdfapp.image->h < _nit_mode.height()) - dst_line += dst_line_width*((_nit_mode.height() - _pdfapp.image->h)/2); + if ((unsigned)_pdfapp.image->h < _nit_mode.area.h()) + dst_line += dst_line_width*((_nit_mode.area.h() - _pdfapp.image->h)/2); /* center horizontally if the dst buffer is wider than the image */ - if (_pdfapp.image->w < _nit_mode.width()) - dst_line += (_nit_mode.width() - _pdfapp.image->w)/2; + if ((unsigned)_pdfapp.image->w < _nit_mode.area.w()) + dst_line += (_nit_mode.area.w() - _pdfapp.image->w)/2; for (int y = 0; y < tweaked_y_max; y++) { - convert_line_rgba_to_rgb565(src_line, dst_line, x_max, y); + copy_line_rgba(src_line, dst_line, x_max); src_line += src_line_bytes; dst_line += dst_line_width; } diff --git a/repos/libports/src/drivers/framebuffer/vesa/README b/repos/libports/src/drivers/framebuffer/vesa/README index 577b4103b5..aa21170b26 100644 --- a/repos/libports/src/drivers/framebuffer/vesa/README +++ b/repos/libports/src/drivers/framebuffer/vesa/README @@ -35,35 +35,7 @@ be set to '"yes"' to prevent the driver from changing the mode. This way, the driver will just query the current mode and make the already initialized framebuffer available to its client. - -Options and usage from clients -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:Example: - - ! #include - ! - ! ... - ! - ! /* create session to frame-buffer service */ - ! Framebuffer::Connection framebuffer(1024, 768, Framebuffer::Session::RGB565); - ! - ! /* retrieve frame buffer dataspace */ - ! Dataspace_capability fb_ds_cap = framebuffer.dataspace(); - ! - ! /* map dataspace to local address space */ - ! void *local_addr = env()->rm_session()->attach(fb_ds_cap); - -:Session-creation arguments: - - :'fb_width': resolution width in pixel - - :'fb_height': resolution height in pixel - - :'fb_mode ': bits per pixel - :Supported modes: - '640x480', '800x600', '1024x786', '1280x1024' at 15, 16, 24, 32 bits per pixel - Buffered output is only supported for modes using 16 bits per pixel. + '640x480', '800x600', '1024x786', '1280x1024' at 32 bits per pixel. diff --git a/repos/libports/src/drivers/framebuffer/vesa/main.cc b/repos/libports/src/drivers/framebuffer/vesa/main.cc index 505a5f0f8f..4ec88818f1 100644 --- a/repos/libports/src/drivers/framebuffer/vesa/main.cc +++ b/repos/libports/src/drivers/framebuffer/vesa/main.cc @@ -71,7 +71,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object /* determine bytes per pixel */ int bypp = 0; - if (_scr_depth == 16) bypp = 2; + if (_scr_depth == 32) bypp = 4; if (!bypp) return; /* copy pixels from back buffer to physical frame buffer */ @@ -99,11 +99,6 @@ class Framebuffer::Session_component : public Genode::Rpc_object { if (!buffered) return; - if (_scr_depth != 16) { - Genode::warning("buffered mode not supported for depth ", _scr_depth); - return; - } - size_t const bb_size = _scr_width*_scr_height*_scr_depth/8; try { _bb.construct(env.ram(), env.rm(), bb_size); } catch (...) { @@ -140,8 +135,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object Mode mode() const override { - return Mode(_scr_width, _scr_height, - _scr_depth == 16 ? Mode::RGB565 : Mode::INVALID); + return Mode { .area = { _scr_width, _scr_height } }; } void mode_sigh(Genode::Signal_context_capability) override { } @@ -191,9 +185,9 @@ class Framebuffer::Root : public Root_component { unsigned scr_width = _session_arg("width", args, "fb_width", 0); unsigned scr_height = _session_arg("height", args, "fb_height", 0); - unsigned const scr_depth = _session_arg("depth", args, "fb_mode", 16); + unsigned const scr_depth = 32; - bool const buffered = _config.xml().attribute_value("buffered", false); + bool const buffered = _config.xml().attribute_value("buffered", true); if (Framebuffer::set_mode(scr_width, scr_height, scr_depth) != 0) { Genode::warning("Could not set vesa mode ", @@ -233,6 +227,7 @@ struct Framebuffer::Main Main(Genode::Env &env) : env(env) { + Genode::log("modified"); try { Framebuffer::init(env, heap); } catch (...) { Genode::error("H/W driver init failed"); throw; diff --git a/repos/libports/src/lib/mesa/i965/platform_i965.c b/repos/libports/src/lib/mesa/i965/platform_i965.c index f5b36dfb03..6294920481 100644 --- a/repos/libports/src/lib/mesa/i965/platform_i965.c +++ b/repos/libports/src/lib/mesa/i965/platform_i965.c @@ -32,8 +32,8 @@ static int stride(int value) { - /* RGB556 */ - return value * 2; + /* 32-bit RGB888 */ + return value * 4; } typedef void *(*mem_copy_fn)(void *dest, const void *src, size_t n); @@ -189,7 +189,7 @@ EGLBoolean dri2_initialize_genode_backend(_EGLDriver *drv, _EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy; - static unsigned rgb565_masks[4] = { 0xf800, 0x07e0, 0x001f, 0 }; + static unsigned rgb888_masks[4] = { 0xff0000, 0xff00, 0xff, 0 }; int i; /* initialize DRM back end */ @@ -227,21 +227,19 @@ dri2_initialize_genode_backend(_EGLDriver *drv, _EGLDisplay *disp) if (!dri2_create_screen(disp)) goto close_screen; - - /* add RGB565 only */ EGLint attrs[] = { EGL_DEPTH_SIZE, 0, /* set in loop below (from DRI config) */ EGL_NATIVE_VISUAL_TYPE, 0, EGL_NATIVE_VISUAL_ID, 0, - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, EGL_NONE }; for (i = 1; dri2_dpy->driver_configs[i]; i++) { /* set depth size in attrs */ attrs[1] = dri2_dpy->driver_configs[i]->modes.depthBits; - dri2_add_config(disp, dri2_dpy->driver_configs[i], i, EGL_WINDOW_BIT, attrs, rgb565_masks); + dri2_add_config(disp, dri2_dpy->driver_configs[i], i, EGL_WINDOW_BIT, attrs, rgb888_masks); } return EGL_TRUE; diff --git a/repos/libports/src/lib/mesa/swrast/platform_swrast.c b/repos/libports/src/lib/mesa/swrast/platform_swrast.c index 4b70e17920..5c7df67d11 100644 --- a/repos/libports/src/lib/mesa/swrast/platform_swrast.c +++ b/repos/libports/src/lib/mesa/swrast/platform_swrast.c @@ -30,8 +30,8 @@ static int stride(int value) { - /* RGB556 */ - return value * 2; + /* 32-bit RGB888 */ + return value * 4; } @@ -152,7 +152,7 @@ static EGLBoolean dri2_initialize_genode_swrast(_EGLDriver *drv, _EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy; - static unsigned rgb565_masks[4] = { 0xf800, 0x07e0, 0x001f, 0 }; + static unsigned rgb888_masks[4] = { 0xff0000, 0xff00, 0xff, 0 }; int i; dri2_dpy = calloc(1, sizeof *dri2_dpy); @@ -180,14 +180,13 @@ dri2_initialize_genode_swrast(_EGLDriver *drv, _EGLDisplay *disp) if (!dri2_create_screen(disp)) goto close_screen; - /* add RGB565 only */ EGLint attrs[] = { EGL_DEPTH_SIZE, 0, /* set in loop below (from DRI config) */ EGL_NATIVE_VISUAL_TYPE, 0, EGL_NATIVE_VISUAL_ID, 0, - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, EGL_NONE }; for (i = 1; dri2_dpy->driver_configs[i]; i++) { @@ -195,7 +194,7 @@ dri2_initialize_genode_swrast(_EGLDriver *drv, _EGLDisplay *disp) attrs[1] = dri2_dpy->driver_configs[i]->modes.depthBits; dri2_add_config(disp, dri2_dpy->driver_configs[i], i, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, attrs, - rgb565_masks); + rgb888_masks); } return EGL_TRUE; diff --git a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/genode/qgenodeplatformwindow.cpp b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/genode/qgenodeplatformwindow.cpp index 83d0264886..bdcbd83475 100644 --- a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/genode/qgenodeplatformwindow.cpp +++ b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/genode/qgenodeplatformwindow.cpp @@ -381,20 +381,18 @@ void QGenodePlatformWindow::_handle_mode_changed() { Framebuffer::Mode mode(_gui_session.mode()); - if ((mode.width() == 0) && (mode.height() == 0)) { + if ((mode.area.w() == 0) && (mode.area.h() == 0)) { /* interpret a size of 0x0 as indication to close the window */ QWindowSystemInterface::handleCloseEvent(window(), 0); /* don't actually set geometry to 0x0; either close or remain open */ return; } - if ((mode.width() != _current_mode.width()) || - (mode.height() != _current_mode.height()) || - (mode.format() != _current_mode.format())) { + if (mode.area != _current_mode.area) { QRect geo(geometry()); - geo.setWidth(mode.width()); - geo.setHeight(mode.height()); + geo.setWidth (mode.area.w()); + geo.setHeight(mode.area.h()); QWindowSystemInterface::handleGeometryChange(window(), geo); @@ -449,8 +447,8 @@ void QGenodePlatformWindow::_adjust_and_set_geometry(const QRect &rect) QPlatformWindow::setGeometry(adjusted_rect); - Framebuffer::Mode mode(adjusted_rect.width(), adjusted_rect.height(), - Framebuffer::Mode::RGB565); + Framebuffer::Mode const mode { .area = { (unsigned)adjusted_rect.width(), + (unsigned)adjusted_rect.height() } }; _gui_session.buffer(mode, false); _current_mode = mode; diff --git a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/genode/qgenodescreen.h b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/genode/qgenodescreen.h index 837c7a4aa0..56957aa97e 100644 --- a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/genode/qgenodescreen.h +++ b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/genode/qgenodescreen.h @@ -42,16 +42,13 @@ class QGenodeScreen : public QPlatformScreen Framebuffer::Mode const scr_mode = _gui.mode(); - if (scr_mode.format() != Framebuffer::Mode::RGB565) - qCritical() << "GUI screen format is not RGB565"; - - _geometry.setRect(0, 0, scr_mode.width(), - scr_mode.height()); + _geometry.setRect(0, 0, scr_mode.area.w(), + scr_mode.area.h()); } QRect geometry() const { return _geometry; } - int depth() const { return 16; } - QImage::Format format() const { return QImage::Format_RGB16; } + int depth() const { return 32; } + QImage::Format format() const { return QImage::Format_ARGB32; } QDpi logicalDpi() const { return QDpi(80, 80); }; QPlatformCursor *cursor() const diff --git a/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc b/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc index 9773ea8ade..a2af966525 100644 --- a/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc +++ b/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc @@ -57,12 +57,14 @@ struct Window : Genode_egl_window Window(Genode::Env &env, int w, int h) : env(env), - mode_dispatcher(*signal_ep, *this, &Window::mode_handler) + mode_dispatcher(*signal_ep, *this, &Window::mode_handler) { width = w; height = h; - framebuffer.construct(env, Framebuffer::Mode(width, height, Framebuffer::Mode::RGB565)); + Framebuffer::Mode const mode { .area = { (unsigned)width, (unsigned)height } }; + + framebuffer.construct(env, mode); addr = env.rm().attach(framebuffer->dataspace()); framebuffer->mode_sigh(mode_dispatcher); @@ -87,10 +89,10 @@ struct Window : Genode_egl_window eglut_window *win = _eglut->current; if (win) { - win->native.width = mode.width(); - win->native.height = mode.height(); - width = mode.width(); - height = mode.height(); + win->native.width = mode.area.w(); + win->native.height = mode.area.h(); + width = mode.area.w(); + height = mode.area.h(); if (win->reshape_cb) win->reshape_cb(win->native.width, win->native.height); diff --git a/repos/os/include/framebuffer_session/connection.h b/repos/os/include/framebuffer_session/connection.h index 1daa34d6fc..17fe028fbb 100644 --- a/repos/os/include/framebuffer_session/connection.h +++ b/repos/os/include/framebuffer_session/connection.h @@ -33,9 +33,7 @@ class Framebuffer::Connection : public Genode::Connection, /** * Create session and return typed session capability */ - Session_capability _connect(Genode::Parent &parent, - unsigned width, unsigned height, - Mode::Format format) + Session_capability _connect(Genode::Parent &parent, Area area) { using namespace Genode; @@ -48,12 +46,10 @@ class Framebuffer::Connection : public Genode::Connection, Arg_string::set_arg(argbuf, sizeof(argbuf), "cap_quota", CAP_QUOTA); /* set optional session-constructor arguments */ - if (width) - Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_width", width); - if (height) - Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_height", height); - if (format != Mode::INVALID) - Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_format", format); + if (area.w()) + Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_width", area.w()); + if (area.h()) + Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_height", area.h()); return session(parent, argbuf); } @@ -72,8 +68,7 @@ class Framebuffer::Connection : public Genode::Connection, Connection(Genode::Env &env, Framebuffer::Mode mode) : Genode::Connection(env, _connect(env.parent(), - mode.width(), mode.height(), - mode.format())), + mode.area)), Session_client(cap()) { } }; diff --git a/repos/os/include/framebuffer_session/framebuffer_session.h b/repos/os/include/framebuffer_session/framebuffer_session.h index 9d2425ce84..99422238d4 100644 --- a/repos/os/include/framebuffer_session/framebuffer_session.h +++ b/repos/os/include/framebuffer_session/framebuffer_session.h @@ -18,12 +18,15 @@ #include #include #include +#include namespace Framebuffer { struct Mode; struct Session; struct Session_client; + + using Area = Genode::Surface_base::Area; } @@ -32,57 +35,11 @@ namespace Framebuffer { */ struct Framebuffer::Mode { - public: + Area area; - /** - * Pixel formats - */ - enum Format { INVALID, RGB565 }; + Genode::size_t bytes_per_pixel() const { return 4; } - static Genode::size_t bytes_per_pixel(Format format) - { - if (format == RGB565) return 2; - return 0; - } - - private: - - int _width = 0, _height = 0; - - 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: - - Mode() { } - - Mode(int width, int height, Format format) - : _width(width), _height(height), _format(format) { } - - int width() const { return _sanitized(_width); } - int height() const { return _sanitized(_height); } - Format format() const { return _sanitized(_format); } - - /** - * Return number of bytes per pixel - */ - Genode::size_t bytes_per_pixel() const { - return bytes_per_pixel(format()); } - - void print(Genode::Output &out) const - { - Genode::print(out, width(), "x", height(), "@"); - switch (format()) { - case RGB565: Genode::print(out, "RGB565"); break; - default: Genode::print(out, "INVALID"); break; - } - } + void print(Genode::Output &out) const { Genode::print(out, area); } }; diff --git a/repos/os/include/gui_session/gui_session.h b/repos/os/include/gui_session/gui_session.h index 8130c045f4..1aaf82b158 100644 --- a/repos/os/include/gui_session/gui_session.h +++ b/repos/os/include/gui_session/gui_session.h @@ -325,7 +325,7 @@ struct Gui::Session : Genode::Session * If alpha blending is used, each pixel requires an additional byte * for the alpha value and a byte holding the input mask. */ - return (mode.bytes_per_pixel() + 2*use_alpha)*mode.width()*mode.height(); + return (mode.bytes_per_pixel() + 2*use_alpha)*mode.area.count(); } diff --git a/repos/os/include/os/pixel_rgb888.h b/repos/os/include/os/pixel_rgb888.h index 282207a0af..e318b66bf2 100644 --- a/repos/os/include/os/pixel_rgb888.h +++ b/repos/os/include/os/pixel_rgb888.h @@ -22,6 +22,15 @@ namespace Genode { 0xff0000, 16, 0xff00, 8, 0xff, 0, 0, 0> Pixel_rgb888; + template <> + inline Pixel_rgb888 Pixel_rgb888::avr(Pixel_rgb888 p1, Pixel_rgb888 p2) + { + Pixel_rgb888 res; + res.pixel = (((p1.pixel&0xfe00fe00)>>1) + ((p2.pixel&0xfe00fe00)>>1)) + | (((p1.pixel&0x00fe00fe)>>1) + ((p2.pixel&0x00fe00fe)>>1)); + return res; + } + template <> inline Pixel_rgb888 Pixel_rgb888::blend(Pixel_rgb888 src, int alpha) { @@ -37,7 +46,7 @@ namespace Genode { { Pixel_rgb888 res; - res.pixel = blend(p1, 255 - alpha).pixel + blend(p2, alpha).pixel; + res.pixel = blend(p1, 256 - alpha).pixel + blend(p2, alpha).pixel; return res; } } diff --git a/repos/os/recipes/raw/drivers_interactive-linux/drivers.config b/repos/os/recipes/raw/drivers_interactive-linux/drivers.config index 4e145a6903..330ea8a8ca 100644 --- a/repos/os/recipes/raw/drivers_interactive-linux/drivers.config +++ b/repos/os/recipes/raw/drivers_interactive-linux/drivers.config @@ -14,7 +14,7 @@ - + diff --git a/repos/os/recipes/raw/drivers_interactive-muen/drivers.config b/repos/os/recipes/raw/drivers_interactive-muen/drivers.config index b5f38a3679..37edf8a053 100644 --- a/repos/os/recipes/raw/drivers_interactive-muen/drivers.config +++ b/repos/os/recipes/raw/drivers_interactive-muen/drivers.config @@ -44,7 +44,7 @@ - + @@ -87,7 +87,7 @@ - + diff --git a/repos/os/recipes/raw/drivers_interactive-pc/drivers.config b/repos/os/recipes/raw/drivers_interactive-pc/drivers.config index d6f2bd7646..cf46aca1f4 100644 --- a/repos/os/recipes/raw/drivers_interactive-pc/drivers.config +++ b/repos/os/recipes/raw/drivers_interactive-pc/drivers.config @@ -77,7 +77,7 @@ - + diff --git a/repos/os/recipes/src/boot_fb_drv/used_apis b/repos/os/recipes/src/boot_fb_drv/used_apis index 80638908f6..254aab69aa 100644 --- a/repos/os/recipes/src/boot_fb_drv/used_apis +++ b/repos/os/recipes/src/boot_fb_drv/used_apis @@ -1,4 +1,5 @@ base os +blit framebuffer_session timer_session diff --git a/repos/os/run/demo.run b/repos/os/run/demo.run index ba453ffd64..2b6432fe87 100644 --- a/repos/os/run/demo.run +++ b/repos/os/run/demo.run @@ -42,7 +42,7 @@ install_config { - + @@ -147,7 +147,7 @@ install_config { - + @@ -185,7 +185,7 @@ install_config { - + } @@ -199,11 +199,11 @@ puts $launchpad_config_fd { - - + + - + diff --git a/repos/os/run/fb_bench.run b/repos/os/run/fb_bench.run index befc5458d9..ae366b32ac 100644 --- a/repos/os/run/fb_bench.run +++ b/repos/os/run/fb_bench.run @@ -40,7 +40,7 @@ install_config { - + diff --git a/repos/os/run/framebuffer.run b/repos/os/run/framebuffer.run index c7bf53d3e3..ec09d79b86 100644 --- a/repos/os/run/framebuffer.run +++ b/repos/os/run/framebuffer.run @@ -27,8 +27,8 @@ install_config { - - + + diff --git a/repos/os/run/loader.run b/repos/os/run/loader.run index 04fb89afb5..dd4af94cd5 100644 --- a/repos/os/run/loader.run +++ b/repos/os/run/loader.run @@ -31,8 +31,8 @@ install_config { - - + + diff --git a/repos/os/src/app/pointer/main.cc b/repos/os/src/app/pointer/main.cc index dcfa914f85..82a13d5fd9 100644 --- a/repos/os/src/app/pointer/main.cc +++ b/repos/os/src/app/pointer/main.cc @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -42,7 +42,7 @@ void convert_default_pointer_data_to_pixels(PT *pixel, Gui::Area size) for (unsigned y = 0; y < size.h(); y++) { for (unsigned x = 0; x < size.w(); x++) { - /* the source is known to be in RGB565 format */ + /* the source is known to be in RGB888 format */ Genode::Pixel_rgb565 src = *(Genode::Pixel_rgb565 *)(&big_mouse.pixels[y][x]); @@ -139,9 +139,7 @@ void Pointer::Main::_resize_gui_buffer_if_needed(Gui::Area pointer_size) if (pointer_size == _current_pointer_size) return; - Framebuffer::Mode const mode { (int)pointer_size.w(), - (int)pointer_size.h(), - Framebuffer::Mode::RGB565 }; + Framebuffer::Mode const mode { .area = pointer_size }; _gui.buffer(mode, true /* use alpha */); @@ -169,7 +167,7 @@ void Pointer::Main::_show_default_pointer() Genode::Attached_dataspace ds { _env.rm(), _pointer_ds }; - convert_default_pointer_data_to_pixels(ds.local_addr(), + convert_default_pointer_data_to_pixels(ds.local_addr(), pointer_size); _gui.framebuffer()->refresh(0, 0, pointer_size.w(), pointer_size.h()); @@ -220,12 +218,12 @@ void Pointer::Main::_show_shape_pointer(Shape_report &shape_report) Attached_dataspace ds { _env.rm(), _pointer_ds }; - Pixel_rgb565 *pixel = ds.local_addr(); + Pixel_rgb888 *pixel = ds.local_addr(); Pixel_alpha8 *alpha = reinterpret_cast(pixel + shape_size.count()); - Surface pixel_surface(pixel, shape_size); + Surface pixel_surface(pixel, shape_size); Surface alpha_surface(alpha, shape_size); Dither_painter::paint(pixel_surface, texture); @@ -341,8 +339,7 @@ Pointer::Main::Main(Genode::Env &env) : _env(env) * pointer size to let the user know right from the start if the * RAM quota is too low. */ - Framebuffer::Mode const mode { Pointer::MAX_WIDTH, Pointer::MAX_HEIGHT, - Framebuffer::Mode::RGB565 }; + Framebuffer::Mode const mode { .area = { Pointer::MAX_WIDTH, Pointer::MAX_HEIGHT } }; _gui.buffer(mode, true /* use alpha */); @@ -353,7 +350,7 @@ Pointer::Main::Main(Genode::Env &env) : _env(env) _handle_hover(); } catch (Genode::Rom_connection::Rom_connection_failed) { Genode::warning("Could not open ROM session for \"hover\".", - " This ROM is used for custom pointer shape support."); + " This ROM is used for custom pointer shape support."); } try { @@ -362,7 +359,7 @@ Pointer::Main::Main(Genode::Env &env) : _env(env) _handle_xray(); } catch (Genode::Rom_connection::Rom_connection_failed) { Genode::warning("Could not open ROM session for \"xray\".", - " This ROM is used for custom pointer shape support."); + " This ROM is used for custom pointer shape support."); } } diff --git a/repos/os/src/app/status_bar/main.cc b/repos/os/src/app/status_bar/main.cc index bb8ab1cf46..632742c2fe 100644 --- a/repos/os/src/app/status_bar/main.cc +++ b/repos/os/src/app/status_bar/main.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ struct Status_bar::Buffer * The status bar is as wide as nitpicker's screen and has a fixed * height. */ - Framebuffer::Mode const _mode { _nit_mode.width(), HEIGHT, _nit_mode.format() }; + Framebuffer::Mode const _mode { .area = { _nit_mode.area.w(), HEIGHT } }; Dataspace_capability _init_buffer() { @@ -120,14 +120,9 @@ void Status_bar::Buffer::draw(Domain_name const &domain_name, Label const &label, Color color) { - if (_mode.format() != Framebuffer::Mode::RGB565) { - error("pixel format not supported"); - return; - } + typedef Pixel_rgb888 PT; - typedef Pixel_rgb565 PT; - - Area const area(_mode.width(), _mode.height()); + Area const area = _mode.area; Surface surface(_fb_ds.local_addr(), area); @@ -248,8 +243,7 @@ void Status_bar::Main::_handle_mode() _draw_status_bar(); - Rect const geometry(Point(0, 0), Area(_buffer->mode().width(), - _buffer->mode().height())); + Rect const geometry(Point(0, 0), _buffer->mode().area); _gui.enqueue(_view, geometry); _gui.execute(); diff --git a/repos/os/src/drivers/framebuffer/boot/framebuffer.cc b/repos/os/src/drivers/framebuffer/boot/framebuffer.cc index 2d70adb608..15fdf9cdcf 100644 --- a/repos/os/src/drivers/framebuffer/boot/framebuffer.cc +++ b/repos/os/src/drivers/framebuffer/boot/framebuffer.cc @@ -13,6 +13,7 @@ #include #include +#include using namespace Framebuffer; @@ -50,7 +51,7 @@ Session_component::Session_component(Genode::Env &env, _fb_mem.construct(_env, _core_fb.addr, _core_fb.pitch * _core_fb.height, true); - _fb_mode = Mode(_core_fb.width, _core_fb.height, Mode::RGB565); + _fb_mode = Mode { .area = { _core_fb.width, _core_fb.height } }; _fb_ram.construct(_env.ram(), _env.rm(), _core_fb.width * _core_fb.height * _fb_mode.bytes_per_pixel()); @@ -70,28 +71,24 @@ void Session_component::refresh(int const x, int const y, int const w, int const { using namespace Genode; - uint32_t const c_x = x < 0 ? 0U : x; - uint32_t const c_y = y < 0 ? 0U : y; - uint32_t const c_w = w < 0 ? 0U : w; - uint32_t const c_h = h < 0 ? 0U : h; + int const width = _core_fb.width; + int const height = _core_fb.height; + unsigned const bpp = 4; + unsigned const pitch = _core_fb.pitch; - uint32_t const u_x = min(_core_fb.width, max(c_x, 0U)); - uint32_t const u_y = min(_core_fb.height, max(c_y, 0U)); - uint32_t const u_w = min(_core_fb.width, max(c_w, 0U) + u_x); - uint32_t const u_h = min(_core_fb.height, max(c_h, 0U) + u_y); + /* clip specified coordinates against screen boundaries */ + int const x2 = min(x + w - 1, width - 1), + y2 = min(y + h - 1, height - 1); + int const x1 = max(x, 0), + y1 = max(y, 0); + if (x1 > x2 || y1 > y2) + return; - Pixel_rgb888 * const pixel_32 = _fb_mem->local_addr(); - Pixel_rgb565 const * const pixel_16 = _fb_ram->local_addr(); + /* copy pixels from back buffer to physical frame buffer */ + char const *src = _fb_ram->local_addr() + bpp*width*y1 + bpp*x1; + char *dst = _fb_mem->local_addr() + pitch*y1 + bpp*x1; - for (uint32_t r = u_y; r < u_h; ++r) { - for (uint32_t c = u_x; c < u_w; ++c) { - uint32_t const s = c + r * _core_fb.width; - uint32_t const d = c + r * (_core_fb.pitch / (_core_fb.bpp / 8)); - - pixel_32[d].rgba(pixel_16[s].r(), pixel_16[s].g(), - pixel_16[s].b(), 0); - } - } + blit(src, bpp*width, dst, pitch, bpp*(x2 - x1 + 1), y2 - y1 + 1); } Genode::Dataspace_capability Session_component::dataspace() diff --git a/repos/os/src/drivers/framebuffer/boot/target.mk b/repos/os/src/drivers/framebuffer/boot/target.mk index a12eb6fea6..884d4b3726 100644 --- a/repos/os/src/drivers/framebuffer/boot/target.mk +++ b/repos/os/src/drivers/framebuffer/boot/target.mk @@ -1,4 +1,4 @@ TARGET = fb_boot_drv -LIBS = base +LIBS = base blit SRC_CC = main.cc framebuffer.cc INC_DIR += $(PRG_DIR)/include diff --git a/repos/os/src/drivers/framebuffer/pl11x/main.cc b/repos/os/src/drivers/framebuffer/pl11x/main.cc index 19d966308d..81d9f05635 100644 --- a/repos/os/src/drivers/framebuffer/pl11x/main.cc +++ b/repos/os/src/drivers/framebuffer/pl11x/main.cc @@ -41,7 +41,7 @@ namespace Framebuffer HSYNC_LEN = 64, VSYNC_LEN = 25, - BYTES_PER_PIXEL = 2, + BYTES_PER_PIXEL = 4, FRAMEBUFFER_SIZE = SCR_WIDTH*SCR_HEIGHT*BYTES_PER_PIXEL, }; @@ -65,13 +65,12 @@ class Framebuffer::Session_component : /** * Bit definitions of the lcd control register */ - CTRL_ENABLED = 1 << 0, - CTRL_BPP16 = 4 << 1, - CTRL_BPP16_565 = 6 << 1, - CTRL_TFT = 1 << 5, - CTRL_BGR = 1 << 8, - CTRL_POWER = 1 << 11, - CTRL_VCOMP = 1 << 12, + CTRL_ENABLED = 1 << 0, + CTRL_BPP_24 = 5 << 1, + CTRL_TFT = 1 << 5, + CTRL_BGR = 1 << 8, + CTRL_POWER = 1 << 11, + CTRL_VCOMP = 1 << 12, /** * Bit definitions for CLCDC timing. @@ -151,7 +150,7 @@ class Framebuffer::Session_component : _timer.msleep(100); } - ctrl = CTRL_BGR | CTRL_ENABLED | CTRL_TFT | CTRL_VCOMP | CTRL_BPP16_565; + ctrl = CTRL_BGR | CTRL_ENABLED | CTRL_TFT | CTRL_VCOMP | CTRL_BPP_24; /* init color-lcd oscillator */ sys_reg_write(SP810_REG_LOCK, 0xa05f); @@ -177,7 +176,7 @@ class Framebuffer::Session_component : Genode::Dataspace_capability dataspace() override { return _fb_ds_cap; } - Mode mode() const override { return Mode(SCR_WIDTH, SCR_HEIGHT, Mode::RGB565); } + Mode mode() const override { return Mode { .area { SCR_WIDTH, SCR_HEIGHT } }; } void mode_sigh(Genode::Signal_context_capability) override { } diff --git a/repos/os/src/drivers/framebuffer/spec/imx53/driver.h b/repos/os/src/drivers/framebuffer/spec/imx53/driver.h index e64c7fa01d..c27f91cc55 100644 --- a/repos/os/src/drivers/framebuffer/spec/imx53/driver.h +++ b/repos/os/src/drivers/framebuffer/spec/imx53/driver.h @@ -66,7 +66,7 @@ class Framebuffer::Driver return true; } - Mode mode() { return Mode(_width, _height, Mode::RGB565); } + Mode mode() { return Mode { .area = { _width, _height } }; } Ipu &ipu() { return _ipu; } }; diff --git a/repos/os/src/drivers/framebuffer/spec/imx53/ipu.h b/repos/os/src/drivers/framebuffer/spec/imx53/ipu.h index 11d87cbdb1..4d9067e798 100644 --- a/repos/os/src/drivers/framebuffer/spec/imx53/ipu.h +++ b/repos/os/src/drivers/framebuffer/spec/imx53/ipu.h @@ -225,24 +225,25 @@ class Ipu : Genode::Mmio cpmem.sly = stride - 1; cpmem.eba0 = phys_base >> 3; cpmem.eba1 = phys_base >> 3; - cpmem.bpp = 3; /* corresponds to 16BPP */ + cpmem.bpp = 0; /* corresponds to 32BPP */ cpmem.pfs = 7; /* corresponds to RGB */ - cpmem.npb = 31; /* 32 pixel per burst access */ + cpmem.npb = 15; /* red */ - cpmem.wid0 = 4; - cpmem.off0 = 0; + cpmem.wid0 = 7; + cpmem.off0 = 8; /* green */ - cpmem.wid1 = 5; - cpmem.off1 = 5; + cpmem.wid1 = 7; + cpmem.off1 = 16; /* blue */ - cpmem.wid2 = 4; cpmem.off2 = 11; + cpmem.wid2 = 7; + cpmem.off2 = 24; /* alpha */ cpmem.wid3 = 7; - cpmem.off3 = 16; + cpmem.off3 = 0; Genode::memcpy(dst, (void*)&cpmem, sizeof(Cp_mem)); } diff --git a/repos/os/src/drivers/framebuffer/spec/imx53/main.cc b/repos/os/src/drivers/framebuffer/spec/imx53/main.cc index 2bd74b0f8f..0a9d644af4 100644 --- a/repos/os/src/drivers/framebuffer/spec/imx53/main.cc +++ b/repos/os/src/drivers/framebuffer/spec/imx53/main.cc @@ -57,8 +57,8 @@ class Framebuffer::Session_component : void _refresh_buffered(int x, int y, int w, int h) { /* clip specified coordinates against screen boundaries */ - int x2 = min(x + w - 1, (int)_mode.width() - 1), - y2 = min(y + h - 1, (int)_mode.height() - 1); + int x2 = min(x + w - 1, (int)_mode.area.w() - 1), + y2 = min(y + h - 1, (int)_mode.area.h() - 1); int x1 = max(x, 0), y1 = max(y, 0); if (x1 > x2 || y1 > y2) return; @@ -66,10 +66,10 @@ class Framebuffer::Session_component : int bypp = _mode.bytes_per_pixel(); /* copy pixels from back buffer to physical frame buffer */ - char *src = (char *)_bb_addr + bypp*(_mode.width()*y1 + x1), - *dst = (char *)_fb_addr + bypp*(_mode.width()*y1 + x1); + char *src = (char *)_bb_addr + bypp*(_mode.area.w()*y1 + x1), + *dst = (char *)_fb_addr + bypp*(_mode.area.h()*y1 + x1); - blit(src, bypp*_mode.width(), dst, bypp*_mode.width(), + blit(src, bypp*_mode.area.w(), dst, bypp*_mode.area.w(), bypp*(x2 - x1 + 1), y2 - y1 + 1); } @@ -79,7 +79,7 @@ class Framebuffer::Session_component : : _env(env), _buffered(buffered), _mode(driver.mode()), - _size(_mode.bytes_per_pixel() * _mode.width() * _mode.height()), + _size(_mode.bytes_per_pixel()*_mode.area.count()), _bb_ds(buffered ? _env.ram().alloc(_size) : Genode::Ram_dataspace_capability()), _bb_addr(buffered ? (void*)_env.rm().attach(_bb_ds) : 0), diff --git a/repos/os/src/drivers/framebuffer/spec/rpi/README b/repos/os/src/drivers/framebuffer/spec/rpi/README new file mode 100644 index 0000000000..7c2698e961 --- /dev/null +++ b/repos/os/src/drivers/framebuffer/spec/rpi/README @@ -0,0 +1,2 @@ +If you find the red and blue color channels swapped, you may need to specify +the option 'framebuffer_swap=1' in you Raspberry Pi's config.txt. diff --git a/repos/os/src/drivers/framebuffer/spec/rpi/main.cc b/repos/os/src/drivers/framebuffer/spec/rpi/main.cc index f38510c2ff..961c21962d 100644 --- a/repos/os/src/drivers/framebuffer/spec/rpi/main.cc +++ b/repos/os/src/drivers/framebuffer/spec/rpi/main.cc @@ -45,8 +45,8 @@ class Framebuffer::Session_component : public Genode::Rpc_object x2 || y1 > y2) return; @@ -89,7 +89,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object _fb_session { }; Constructible> _fb_root { }; diff --git a/repos/os/src/drivers/framebuffer/spec/sdl/main.cc b/repos/os/src/drivers/framebuffer/spec/sdl/main.cc index a830c0fcbb..b1b5e3864e 100644 --- a/repos/os/src/drivers/framebuffer/spec/sdl/main.cc +++ b/repos/os/src/drivers/framebuffer/spec/sdl/main.cc @@ -95,8 +95,8 @@ class Framebuffer::Session_component : public Rpc_object { unsigned const bpp = _requested_mode.bytes_per_pixel(); unsigned const flags = SDL_SWSURFACE | SDL_RESIZABLE; - unsigned const w = _requested_mode.width(); - unsigned const h = _requested_mode.height(); + unsigned const w = _requested_mode.area.w(); + unsigned const h = _requested_mode.area.h(); if (SDL_VideoModeOK(w, h, bpp*8, flags)) _screen = SDL_SetVideoMode(w, h, bpp*8, flags); @@ -153,8 +153,8 @@ class Framebuffer::Session_component : public Rpc_object /* clip refresh area to screen boundaries */ int const x1 = max(x, 0); int const y1 = max(y, 0); - int const x2 = min(x + w - 1, min(_mode.width(), _screen->w) - 1); - int const y2 = min(y + h - 1, min(_mode.height(), _screen->h) - 1); + int const x2 = min(x + w - 1, min((int)_mode.area.w(), _screen->w) - 1); + int const y2 = min(y + h - 1, min((int)_mode.area.h(), _screen->h) - 1); if (x1 > x2 || y1 > y2) return; @@ -163,7 +163,7 @@ class Framebuffer::Session_component : public Rpc_object unsigned const bpp = _mode.bytes_per_pixel(); char const * const src_base = _fb_ds->local_addr(); - unsigned const src_pitch = bpp*_mode.width(); + unsigned const src_pitch = bpp*_mode.area.w(); char const * const src = src_base + y1*src_pitch + bpp*x1; unsigned const dst_pitch = _screen->pitch; @@ -186,10 +186,10 @@ struct Fb_sdl::Main Timer::Connection _timer { _env }; - int _fb_width = _config.xml().attribute_value("width", 1024UL); - int _fb_height = _config.xml().attribute_value("height", 768UL); + unsigned const _fb_width = _config.xml().attribute_value("width", 1024UL); + unsigned const _fb_height = _config.xml().attribute_value("height", 768UL); - Framebuffer::Mode _fb_mode { _fb_width, _fb_height, Framebuffer::Mode::RGB565 }; + Framebuffer::Mode _fb_mode { .area = { _fb_width, _fb_height } }; Framebuffer::Session_component _fb_session { _env, _fb_mode }; @@ -250,9 +250,13 @@ void Fb_sdl::Main::_handle_sdl_event(SDL_Event const &event) if (event.type == SDL_VIDEORESIZE) { - Framebuffer::Mode const mode(event.resize.w, event.resize.h, - Framebuffer::Mode::RGB565); + if (event.resize.w < 0 || event.resize.h < 0) { + warning("attempt to resize to negative size"); + return; + } + Framebuffer::Mode const mode { .area = { (unsigned)event.resize.w, + (unsigned)event.resize.h } }; _fb_session.submit_mode_change(mode); return; } diff --git a/repos/os/src/server/gui_fb/main.cc b/repos/os/src/server/gui_fb/main.cc index 6a9ad75f09..923208896e 100644 --- a/repos/os/src/server/gui_fb/main.cc +++ b/repos/os/src/server/gui_fb/main.cc @@ -97,8 +97,6 @@ struct Framebuffer::Session_component : Genode::Rpc_object View_updater &_view_updater; - Framebuffer::Mode::Format _format = _gui.mode().format(); - /* * Mode as requested by the configuration or by a mode change of our * GUI session. @@ -150,10 +148,10 @@ struct Framebuffer::Session_component : Genode::Rpc_object void size(Gui::Area size) { /* ignore calls that don't change the size */ - if (Gui::Area(_next_mode.width(), _next_mode.height()) == size) + if (Gui::Area(_next_mode.area.w(), _next_mode.area.h()) == size) return; - Framebuffer::Mode const mode(size.w(), size.h(), _next_mode.format()); + Framebuffer::Mode const mode { .area = size }; if (!_ram_suffices_for_mode(mode)) { Genode::warning("insufficient RAM for mode ", mode); @@ -168,7 +166,7 @@ struct Framebuffer::Session_component : Genode::Rpc_object Gui::Area size() const { - return Gui::Area(_active_mode.width(), _active_mode.height()); + return _active_mode.area; } @@ -268,15 +266,15 @@ struct Nit_fb::Main : View_updater unsigned width(Framebuffer::Mode const &mode) const { if (_width > 0) return _width; - if (_width < 0) return mode.width() + _width; - return mode.width(); + if (_width < 0) return mode.area.w() + _width; + return mode.area.w(); } unsigned height(Framebuffer::Mode const &mode) const { if (_height > 0) return _height; - if (_height < 0) return mode.height() + _height; - return mode.height(); + if (_height < 0) return mode.area.h() + _height; + return mode.area.h(); } bool valid() const { return _width != 0 && _height != 0; } @@ -285,9 +283,8 @@ struct Nit_fb::Main : View_updater Framebuffer::Mode _initial_mode() { - return Framebuffer::Mode(_initial_size.width (gui.mode()), - _initial_size.height(gui.mode()), - gui.mode().format()); + return Framebuffer::Mode { .area = { _initial_size.width (gui.mode()), + _initial_size.height(gui.mode()) } }; } /* @@ -327,9 +324,9 @@ struct Nit_fb::Main : View_updater Value const value = config.attribute_value(attr, Value()); if (value == "top_left") return Point(0, 0); - if (value == "top_right") return Point(mode.width(), 0); - if (value == "bottom_left") return Point(0, mode.height()); - if (value == "bottom_right") return Point(mode.width(), mode.height()); + if (value == "top_right") return Point(mode.area.w(), 0); + if (value == "bottom_left") return Point(0, mode.area.h()); + if (value == "bottom_right") return Point(mode.area.w(), mode.area.h()); warning("unsupported ", attr, " attribute value '", value, "'"); return Point(0, 0); @@ -339,9 +336,9 @@ struct Nit_fb::Main : View_updater { Xml_node const config = config_rom.xml(); - Framebuffer::Mode const nit_mode = gui.mode(); + Framebuffer::Mode const gui_mode = gui.mode(); - position = _coordinate_origin(nit_mode, config) + position = _coordinate_origin(gui_mode, config) + Point(config.attribute_value("xpos", 0L), config.attribute_value("ypos", 0L)); @@ -354,15 +351,15 @@ struct Nit_fb::Main : View_updater _initial_size.set = true; } - unsigned const nit_width = nit_mode.width(); - unsigned const nit_height = nit_mode.height(); + unsigned const gui_width = gui_mode.area.w(); + unsigned const gui_height = gui_mode.area.h(); - long width = config.attribute_value("width", (long)nit_mode.width()), - height = config.attribute_value("height", (long)nit_mode.height()); + long width = config.attribute_value("width", (long)gui_mode.area.w()), + height = config.attribute_value("height", (long)gui_mode.area.h()); if (!_initial_size.set && _initial_size.valid()) { - width = _initial_size.width (nit_mode); - height = _initial_size.height(nit_mode); + width = _initial_size.width (gui_mode); + height = _initial_size.height(gui_mode); _initial_size.set = true; } else { @@ -371,8 +368,8 @@ struct Nit_fb::Main : View_updater * If configured width / height values are negative, the effective * width / height is deduced from the screen size. */ - if (width < 0) width = nit_width + width; - if (height < 0) height = nit_height + height; + if (width < 0) width = gui_width + width; + if (height < 0) height = gui_height + height; } fb_session.size(Area(width, height)); diff --git a/repos/os/src/server/loader/gui.h b/repos/os/src/server/loader/gui.h index a572576f89..17cd171301 100644 --- a/repos/os/src/server/loader/gui.h +++ b/repos/os/src/server/loader/gui.h @@ -230,16 +230,15 @@ class Gui::Session_component : public Rpc_object Framebuffer::Mode mode() override { - int mode_width = _max_size.valid() ? - _max_size.w() : - _gui.mode().width(); + unsigned const mode_width = _max_size.valid() ? + _max_size.w() : + _gui.mode().area.w(); - int mode_height = _max_size.valid() ? - _max_size.h() : - _gui.mode().height(); + unsigned const mode_height = _max_size.valid() ? + _max_size.h() : + _gui.mode().area.h(); - return Framebuffer::Mode(mode_width, mode_height, - _gui.mode().format()); + return Framebuffer::Mode { .area = { mode_width, mode_height } }; } void mode_sigh(Signal_context_capability) override { } diff --git a/repos/os/src/server/nitpicker/buffer.h b/repos/os/src/server/nitpicker/buffer.h index 6b8763df7c..abf96b2759 100644 --- a/repos/os/src/server/nitpicker/buffer.h +++ b/repos/os/src/server/nitpicker/buffer.h @@ -29,9 +29,8 @@ class Nitpicker::Buffer { private: - Area _size; - Framebuffer::Mode::Format _format; - Attached_ram_dataspace _ram_ds; + Area _size; + Attached_ram_dataspace _ram_ds; public: @@ -42,19 +41,17 @@ class Nitpicker::Buffer * \throw Out_of_caps * \throw Region_map::Region_conflict */ - Buffer(Ram_allocator &ram, Region_map &rm, - Area size, Framebuffer::Mode::Format format, size_t bytes) + Buffer(Ram_allocator &ram, Region_map &rm, Area size, size_t bytes) : - _size(size), _format(format), _ram_ds(ram, rm, bytes) + _size(size), _ram_ds(ram, rm, bytes) { } /** * Accessors */ - Ram_dataspace_capability ds_cap() const { return _ram_ds.cap(); } - Area size() const { return _size; } - Framebuffer::Mode::Format format() const { return _format; } - void *local_addr() const { return _ram_ds.local_addr(); } + Ram_dataspace_capability ds_cap() const { return _ram_ds.cap(); } + Area size() const { return _size; } + void *local_addr() const { return _ram_ds.local_addr(); } }; diff --git a/repos/os/src/server/nitpicker/chunky_texture.h b/repos/os/src/server/nitpicker/chunky_texture.h index 56ce169f3f..8ed7de4b07 100644 --- a/repos/os/src/server/nitpicker/chunky_texture.h +++ b/repos/os/src/server/nitpicker/chunky_texture.h @@ -25,9 +25,6 @@ class Nitpicker::Chunky_texture : public Buffer, public Texture { private: - Framebuffer::Mode::Format _format() { - return Framebuffer::Mode::RGB565; } - /** * Return base address of alpha channel or 0 if no alpha channel exists */ @@ -46,7 +43,7 @@ class Nitpicker::Chunky_texture : public Buffer, public Texture */ Chunky_texture(Ram_allocator &ram, Region_map &rm, Area size, bool use_alpha) : - Buffer(ram, rm, size, _format(), calc_num_bytes(size, use_alpha)), + Buffer(ram, rm, size, calc_num_bytes(size, use_alpha)), Texture((PT *)local_addr(), _alpha_base(size, use_alpha), size) { } diff --git a/repos/os/src/server/nitpicker/main.cc b/repos/os/src/server/nitpicker/main.cc index 03eedc8f06..223b3a6690 100644 --- a/repos/os/src/server/nitpicker/main.cc +++ b/repos/os/src/server/nitpicker/main.cc @@ -197,13 +197,13 @@ struct Nitpicker::Main : Focus_updater { Env &_env; - Framebuffer::Connection _framebuffer { _env, Framebuffer::Mode() }; + Framebuffer::Connection _framebuffer { _env, Framebuffer::Mode { } }; Input::Connection _input { _env }; Attached_dataspace _ev_ds { _env.rm(), _input.dataspace() }; - typedef Pixel_rgb565 PT; /* physical pixel type */ + typedef Pixel_rgb888 PT; /* physical pixel type */ /* * Initialize framebuffer @@ -219,7 +219,7 @@ struct Nitpicker::Main : Focus_updater Attached_dataspace fb_ds; - Canvas screen = { fb_ds.local_addr(), Area(mode.width(), mode.height()) }; + Canvas screen = { fb_ds.local_addr(), mode.area }; Area size = screen.size(); @@ -608,7 +608,7 @@ void Nitpicker::Main::_handle_fb_mode() _fb_screen.construct(_env.rm(), _framebuffer); /* let the view stack use the new size */ - _view_stack.size(Area(_fb_screen->mode.width(), _fb_screen->mode.height())); + _view_stack.size(_fb_screen->mode.area); /* redraw */ _view_stack.update_all_views(); diff --git a/repos/os/src/server/nitpicker/session_component.cc b/repos/os/src/server/nitpicker/session_component.cc index 8808b039ac..eb611e0156 100644 --- a/repos/os/src/server/nitpicker/session_component.cc +++ b/repos/os/src/server/nitpicker/session_component.cc @@ -21,7 +21,7 @@ void Session_component::_release_buffer() if (!_texture) return; - typedef Pixel_rgb565 PT; + typedef Pixel_rgb888 PT; Chunky_texture const *cdt = static_cast const *>(_texture); @@ -412,15 +412,10 @@ void Session_component::execute() } } + Framebuffer::Mode Session_component::mode() { - Area const phys_area(_framebuffer.mode().width(), - _framebuffer.mode().height()); - - Area const session_area = screen_area(phys_area); - - return Framebuffer::Mode(session_area.w(), session_area.h(), - _framebuffer.mode().format()); + return Framebuffer::Mode { .area = screen_area(_framebuffer.mode().area) }; } @@ -473,11 +468,9 @@ void Session_component::session_control(Label suffix, Session_control control) Buffer *Session_component::realloc_buffer(Framebuffer::Mode mode, bool use_alpha) { - typedef Pixel_rgb565 PT; + typedef Pixel_rgb888 PT; - Area const size(mode.width(), mode.height()); - - _buffer_size = Chunky_texture::calc_num_bytes(size, use_alpha); + _buffer_size = Chunky_texture::calc_num_bytes(mode.area, use_alpha); /* * Preserve the content of the original buffer if nitpicker has @@ -504,7 +497,7 @@ Buffer *Session_component::realloc_buffer(Framebuffer::Mode mode, bool use_alpha { try { return new (&_session_alloc) - Chunky_texture(_env.ram(), _env.rm(), size, use_alpha); + Chunky_texture(_env.ram(), _env.rm(), mode.area, use_alpha); } catch (...) { return (Chunky_texture*)nullptr; } diff --git a/repos/os/src/server/nitpicker/session_component.h b/repos/os/src/server/nitpicker/session_component.h index 40fc135203..82ce6ebb00 100644 --- a/repos/os/src/server/nitpicker/session_component.h +++ b/repos/os/src/server/nitpicker/session_component.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include /* local includes */ diff --git a/repos/os/src/server/nitpicker/view_component.cc b/repos/os/src/server/nitpicker/view_component.cc index 189d626647..711c5d061d 100644 --- a/repos/os/src/server/nitpicker/view_component.cc +++ b/repos/os/src/server/nitpicker/view_component.cc @@ -11,7 +11,7 @@ * under the terms of the GNU Affero General Public License version 3. */ -#include +#include #include #include diff --git a/repos/os/src/test/fb_bench/main.cc b/repos/os/src/test/fb_bench/main.cc index 1b720e9e70..fea82b8512 100644 --- a/repos/os/src/test/fb_bench/main.cc +++ b/repos/os/src/test/fb_bench/main.cc @@ -30,7 +30,7 @@ struct Test int id; Timer::Connection timer { env }; Heap heap { env.ram(), env.rm() }; - Framebuffer::Connection fb { env, Framebuffer::Mode() }; + Framebuffer::Connection fb { env, Framebuffer::Mode { } }; Attached_dataspace fb_ds { env.rm(), fb.dataspace() }; Framebuffer::Mode const fb_mode { fb.mode() }; char *buf[2]; @@ -100,8 +100,8 @@ struct Blit_test : Test { unsigned kib = 0; uint64_t const start_ms = timer.elapsed_ms(); - unsigned const w = fb_mode.width() * fb_mode.bytes_per_pixel(); - unsigned const h = fb_mode.height(); + unsigned const w = fb_mode.area.w() * fb_mode.bytes_per_pixel(); + unsigned const h = fb_mode.area.h(); for (unsigned i = 0; timer.elapsed_ms() - start_ms < DURATION_MS; i++) { blit(buf[i % 2], w, fb_ds.local_addr(), w, w, h); kib += (w * h) / 1024; @@ -118,8 +118,8 @@ struct Unaligned_blit_test : Test { unsigned kib = 0; uint64_t const start_ms = timer.elapsed_ms(); - unsigned const w = fb_mode.width() * fb_mode.bytes_per_pixel(); - unsigned const h = fb_mode.height(); + unsigned const w = fb_mode.area.w() * fb_mode.bytes_per_pixel(); + unsigned const h = fb_mode.area.h(); for (unsigned i = 0; timer.elapsed_ms() - start_ms < DURATION_MS; i++) { blit(buf[i % 2] + 2, w, fb_ds.local_addr() + 2, w, w - 2, h); kib += (w * h) / 1024; diff --git a/repos/os/src/test/framebuffer/main.cc b/repos/os/src/test/framebuffer/main.cc index 6a16af08e4..e60c6a7327 100644 --- a/repos/os/src/test/framebuffer/main.cc +++ b/repos/os/src/test/framebuffer/main.cc @@ -18,10 +18,13 @@ #include #include #include +#include +#include #include -using Genode::uint16_t; +using Area = Genode::Surface_base::Area; +using Pixel = Genode::Pixel_rgb888; class Test_environment { @@ -29,13 +32,11 @@ class Test_environment using Ds = Genode::Constructible; - enum Color { - BLACK = 0x0, - BLUE = 0x1f, - GREEN = 0x7e0, - RED = 0xf800, - WHITE = 0xffff, - }; + Pixel const BLACK = { 0, 0, 0 }; + Pixel const BLUE = { 0, 0, 255 }; + Pixel const GREEN = { 0, 255, 0 }; + Pixel const RED = { 255, 0, 0 }; + Pixel const WHITE = { 255, 255, 255 }; enum State { STRIPES, ALL_BLUE, ALL_GREEN, ALL_RED, COLORED }; @@ -57,7 +58,7 @@ class Test_environment void _sync_handle() { if (_sync_cnt++ % FRAME_CNT == 0) _draw(); } - void _draw_frame(uint16_t volatile *, uint16_t, unsigned, unsigned); + void _draw_frame(Pixel *, Pixel, Area); Genode::size_t _fb_bpp() { return _mode.bytes_per_pixel(); } Genode::size_t _fb_size() { return _fb_ds->size(); } @@ -79,9 +80,10 @@ class Test_environment }; -void Test_environment::_draw_frame(uint16_t volatile *p, uint16_t c, - unsigned const w, unsigned const h) +void Test_environment::_draw_frame(Pixel *p, Pixel c, Area area) { + unsigned const w = area.w(), h = area.h(); + /* top and bottom */ for (unsigned i = 0; i < w; ++i) p[i] = p[(h - 1)*w + i] = c; @@ -100,7 +102,7 @@ void Test_environment::_draw() case STRIPES: { Genode::log("black & white stripes"); - addr_t const stripe_width = _mode.width() / 4; + addr_t const stripe_width = _mode.area.w() / 4; addr_t stripe_o = 0; bool stripe = 0; for (addr_t o = 0; o < _fb_size(); o += _fb_bpp()) { @@ -109,11 +111,10 @@ void Test_environment::_draw() stripe_o = 0; stripe = !stripe; } - *(uint16_t volatile *)(_fb_base() + o) = stripe ? BLACK : WHITE; + *(Pixel *)(_fb_base() + o) = stripe ? BLACK : WHITE; } - _draw_frame((uint16_t volatile *)_fb_base(), RED, - _mode.width(), _mode.height()); + _draw_frame((Pixel *)_fb_base(), RED, _mode.area); _state = ALL_BLUE; break; } @@ -121,10 +122,9 @@ void Test_environment::_draw() { Genode::log("blue"); for (addr_t o = 0; o < _fb_size(); o += _fb_bpp()) - *(uint16_t volatile *)(_fb_base() + o) = BLUE; + *(Pixel *)(_fb_base() + o) = BLUE; - _draw_frame((uint16_t volatile *)_fb_base(), RED, - _mode.width(), _mode.height()); + _draw_frame((Pixel *)_fb_base(), RED, _mode.area); _state = ALL_GREEN; break; } @@ -132,10 +132,9 @@ void Test_environment::_draw() { Genode::log("green"); for (addr_t o = 0; o < _fb_size(); o += _fb_bpp()) - *(uint16_t volatile *)(_fb_base() + o) = GREEN; + *(Pixel *)(_fb_base() + o) = GREEN; - _draw_frame((uint16_t volatile *)_fb_base(), RED, - _mode.width(), _mode.height()); + _draw_frame((Pixel *)_fb_base(), RED, _mode.area); _state = ALL_RED; break; } @@ -143,10 +142,9 @@ void Test_environment::_draw() { Genode::log("red"); for (addr_t o = 0; o < _fb_size(); o += _fb_bpp()) - *(uint16_t volatile *)(_fb_base() + o) = RED; + *(Pixel *)(_fb_base() + o) = RED; - _draw_frame((uint16_t volatile *)_fb_base(), WHITE, - _mode.width(), _mode.height()); + _draw_frame((Pixel *)_fb_base(), WHITE, _mode.area); _state = COLORED; break; } @@ -155,14 +153,13 @@ void Test_environment::_draw() Genode::log("all colors mixed"); unsigned i = 0; for (addr_t o = 0; o < _fb_size(); o += _fb_bpp(), i++) - *(uint16_t volatile *)(_fb_base() + o) = i; + *(Pixel *)(_fb_base() + o) = Pixel(i>>16, i>>8, i); - _draw_frame((uint16_t volatile *)_fb_base(), WHITE, - _mode.width(), _mode.height()); + _draw_frame((Pixel *)_fb_base(), WHITE, _mode.area); _state = STRIPES; } }; - _fb.refresh(0, 0, _mode.width(), _mode.height()); + _fb.refresh(0, 0, _mode.area.w(), _mode.area.h()); } @@ -176,11 +173,6 @@ void Test_environment::_mode_handle() Genode::log("framebuffer is ", _mode); - if (_mode.bytes_per_pixel() != 2) { - Genode::error("pixel format not supported"); - throw -1; - } - _draw(); } diff --git a/repos/os/src/test/nitpicker/test.cc b/repos/os/src/test/nitpicker/test.cc index 623902c396..6285768f6c 100644 --- a/repos/os/src/test/nitpicker/test.cc +++ b/repos/os/src/test/nitpicker/test.cc @@ -18,6 +18,7 @@ #include #include #include +#include using namespace Genode; @@ -150,10 +151,10 @@ void Component::construct(Genode::Env &env) static Gui::Connection gui { env, "testnit" }; static Timer::Connection timer { env }; - Framebuffer::Mode const mode(256, 256, Framebuffer::Mode::RGB565); + Framebuffer::Mode const mode { .area = { 256, 256 } }; gui.buffer(mode, false); - int const scr_w = mode.width(), scr_h = mode.height(); + int const scr_w = mode.area.w(), scr_h = mode.area.h(); log("screen is ", mode); if (!scr_w || !scr_h) { @@ -172,7 +173,8 @@ void Component::construct(Genode::Env &env) Genode::Attached_dataspace fb_ds( env.rm(), gui.framebuffer()->dataspace()); - short *pixels = fb_ds.local_addr(); + typedef Genode::Pixel_rgb888 PT; + PT *pixels = fb_ds.local_addr(); unsigned char *alpha = (unsigned char *)&pixels[scr_w*scr_h]; unsigned char *input_mask = CONFIG_ALPHA ? alpha + scr_w*scr_h : 0; @@ -183,7 +185,7 @@ void Component::construct(Genode::Env &env) */ for (int i = 0; i < scr_h; i++) for (int j = 0; j < scr_w; j++) { - pixels[i*scr_w + j] = (i/8)*32*64 + (j/4)*32 + i*j/256; + pixels[i*scr_w + j] = PT((3*i)/8, j, i*j/32); if (CONFIG_ALPHA) { alpha[i*scr_w + j] = (i*2) ^ (j*2); input_mask[i*scr_w + j] = alpha[i*scr_w + j] > 127; diff --git a/repos/ports/recipes/src/vbox5-nova/used_apis b/repos/ports/recipes/src/vbox5-nova/used_apis index d45e7350cd..a5f5a30828 100644 --- a/repos/ports/recipes/src/vbox5-nova/used_apis +++ b/repos/ports/recipes/src/vbox5-nova/used_apis @@ -16,3 +16,5 @@ terminal_session timer_session usb_session vfs +nitpicker_gfx +blit diff --git a/repos/ports/recipes/src/vbox5/used_apis b/repos/ports/recipes/src/vbox5/used_apis index 1d1f4b4975..a3279065ad 100644 --- a/repos/ports/recipes/src/vbox5/used_apis +++ b/repos/ports/recipes/src/vbox5/used_apis @@ -16,3 +16,5 @@ timer_session usb_session vfs vm_session +nitpicker_gfx +blit diff --git a/repos/ports/run/bash.run b/repos/ports/run/bash.run index 0e3f37f260..1c2de156ed 100644 --- a/repos/ports/run/bash.run +++ b/repos/ports/run/bash.run @@ -48,8 +48,8 @@ install_config { - - + + diff --git a/repos/ports/run/debug_nitpicker.run b/repos/ports/run/debug_nitpicker.run index e9a1840a85..0f51e251df 100644 --- a/repos/ports/run/debug_nitpicker.run +++ b/repos/ports/run/debug_nitpicker.run @@ -65,8 +65,8 @@ install_config { - - + + diff --git a/repos/ports/run/seoul-fancy.run b/repos/ports/run/seoul-fancy.run index 10a83aef67..42f4b63e73 100644 --- a/repos/ports/run/seoul-fancy.run +++ b/repos/ports/run/seoul-fancy.run @@ -37,7 +37,7 @@ set vcpus_to_be_used 1 set multiboot_files { - + } diff --git a/repos/ports/run/seoul.inc b/repos/ports/run/seoul.inc index adb9f1757c..a56863e304 100644 --- a/repos/ports/run/seoul.inc +++ b/repos/ports/run/seoul.inc @@ -351,7 +351,7 @@ append_if [expr $use_nic_session && $use_nic_bridge] config { append_if $use_framebuffer config { - + @@ -359,7 +359,7 @@ append_if $use_framebuffer config { } append_if [expr $use_framebuffer && [have_include "power_on/qemu"]] config { - } + } append_if [expr $use_framebuffer && ![have_include "power_on/qemu"]] config { } append_if $use_framebuffer config { diff --git a/repos/ports/run/vbox5_genode_usb_hid.run b/repos/ports/run/vbox5_genode_usb_hid.run index bd66d14e08..0bdb1cdb5f 100644 --- a/repos/ports/run/vbox5_genode_usb_hid.run +++ b/repos/ports/run/vbox5_genode_usb_hid.run @@ -145,8 +145,9 @@ append config { - + + diff --git a/repos/ports/run/vim.run b/repos/ports/run/vim.run index b22a13934a..f591a256a0 100644 --- a/repos/ports/run/vim.run +++ b/repos/ports/run/vim.run @@ -41,8 +41,8 @@ install_config { - - + + diff --git a/repos/ports/run/virtualbox.run b/repos/ports/run/virtualbox.run index 3fa08d9eb7..511e2df5f5 100644 --- a/repos/ports/run/virtualbox.run +++ b/repos/ports/run/virtualbox.run @@ -102,10 +102,10 @@ append_if [expr $use_usb] config { append_if [have_spec framebuffer] config { - + } append_if [expr [have_spec framebuffer] && [have_include power_on/qemu]] config { - } + } append_if [expr [have_spec framebuffer] && [have_include power_on/qemu]] config { } append_if [have_spec framebuffer] config { diff --git a/repos/ports/run/virtualbox_auto.inc b/repos/ports/run/virtualbox_auto.inc index 431f3bd09b..2c971cb09b 100644 --- a/repos/ports/run/virtualbox_auto.inc +++ b/repos/ports/run/virtualbox_auto.inc @@ -351,7 +351,7 @@ append_if [expr $use_usb] config { append_if [have_spec framebuffer] config { - + } diff --git a/repos/ports/src/app/seoul/component.cc b/repos/ports/src/app/seoul/component.cc index 0030d750e9..c7c99d7f5f 100644 --- a/repos/ports/src/app/seoul/component.cc +++ b/repos/ports/src/app/seoul/component.cc @@ -1388,20 +1388,19 @@ void Component::construct(Genode::Env &env) /* setup framebuffer memory for guest */ static Gui::Connection gui { env }; - gui.buffer(Framebuffer::Mode(width, height, Framebuffer::Mode::RGB565), false); + gui.buffer(Framebuffer::Mode { .area = { width, height } }, false); - static Framebuffer::Session &framebuffer { *gui.framebuffer() }; - Framebuffer::Mode const fb_mode { framebuffer.mode() }; + static Framebuffer::Session &framebuffer { *gui.framebuffer() }; + Framebuffer::Mode const fb_mode { framebuffer.mode() }; - size_t const fb_size = Genode::align_addr(fb_mode.width() * - fb_mode.height() * + size_t const fb_size = Genode::align_addr(fb_mode.area.count() * fb_mode.bytes_per_pixel(), 12); typedef Gui::Session::View_handle View_handle; typedef Gui::Session::Command Command; View_handle view = gui.create_view(); - Gui::Rect rect(Gui::Point(0, 0), Gui::Area(fb_mode.width(), fb_mode.height())); + Gui::Rect rect(Gui::Point(0, 0), fb_mode.area); gui.enqueue(view, rect); gui.enqueue(view, View_handle()); diff --git a/repos/ports/src/app/seoul/console.cc b/repos/ports/src/app/seoul/console.cc index f89bba92ce..2932079b9b 100644 --- a/repos/ports/src/app/seoul/console.cc +++ b/repos/ports/src/app/seoul/console.cc @@ -192,25 +192,26 @@ bool Seoul::Console::receive(MessageConsole &msg) * It's important to set the _vesa_mode field, otherwise the * device model is going to ignore this mode. */ - msg.info->_vesa_mode = 0x114; + unsigned const bpp = _fb_mode.bytes_per_pixel(); + msg.info->_vesa_mode = 0x138; msg.info->attr = 0x39f; - msg.info->resolution[0] = _fb_mode.width(); - msg.info->resolution[1] = _fb_mode.height(); - msg.info->bytes_per_scanline = _fb_mode.width()*2; - msg.info->bytes_scanline = _fb_mode.width()*2; - msg.info->bpp = 16; + msg.info->resolution[0] = _fb_mode.area.w(); + msg.info->resolution[1] = _fb_mode.area.h(); + msg.info->bytes_per_scanline = _fb_mode.area.w()*bpp; + msg.info->bytes_scanline = _fb_mode.area.w()*bpp; + msg.info->bpp = 32; msg.info->memory_model = MEMORY_MODEL_DIRECT_COLOR; - msg.info->vbe1[0] = 0x5; /* red mask size */ - msg.info->vbe1[1] = 0xb; /* red field position */ - msg.info->vbe1[2] = 0x6; /* green mask size */ - msg.info->vbe1[3] = 0x5; /* green field position */ - msg.info->vbe1[4] = 0x5; /* blue mask size */ - msg.info->vbe1[5] = 0x0; /* blue field position */ - msg.info->vbe1[6] = 0x0; /* reserved mask size */ - msg.info->vbe1[7] = 0x0; /* reserved field position */ + msg.info->vbe1[0] = 0x8; /* red mask size */ + msg.info->vbe1[1] = 0x10; /* red field position */ + msg.info->vbe1[2] = 0x8; /* green mask size */ + msg.info->vbe1[3] = 0x8; /* green field position */ + msg.info->vbe1[4] = 0x8; /* blue mask size */ + msg.info->vbe1[5] = 0x0; /* blue field position */ + msg.info->vbe1[6] = 0x0; /* reserved mask size */ + msg.info->vbe1[7] = 0x0; /* reserved field position */ msg.info->colormode = 0x0; /* direct color mode info */ msg.info->phys_base = 0xe0000000; - msg.info->_phys_size = _fb_mode.width()*_fb_mode.height()*2; + msg.info->_phys_size = _fb_mode.area.count()*bpp; return true; } return false; @@ -306,7 +307,7 @@ unsigned Seoul::Console::_handle_fb() /* compare checksums to detect changed buffer */ if (fb_state.checksum1 != fb_state.checksum2) { fb_state.unchanged = 0; - _framebuffer.refresh(0, 0, _fb_mode.width(), _fb_mode.height()); + _framebuffer.refresh(0, 0, _fb_mode.area.w(), _fb_mode.area.h()); return 100; } @@ -320,7 +321,7 @@ unsigned Seoul::Console::_handle_fb() fb_state.vga_revoked = true; fb_state.unchanged = 0; - _framebuffer.refresh(0, 0, _fb_mode.width(), _fb_mode.height()); + _framebuffer.refresh(0, 0, _fb_mode.area.w(), _fb_mode.area.h()); //Logging::printf("Deactivated text buffer loop.\n"); return 0; @@ -338,7 +339,7 @@ unsigned Seoul::Console::_handle_fb() return 0; } - _framebuffer.refresh(0, 0, _fb_mode.width(), _fb_mode.height()); + _framebuffer.refresh(0, 0, _fb_mode.area.w(), _fb_mode.area.h()); fb_state.unchanged++; @@ -422,9 +423,7 @@ Seoul::Console::Console(Genode::Env &env, Genode::Allocator &alloc, _fb_vm_mapping(_env.rm().attach(_fb_vm_ds)), _vm_phys_fb(guest_memory.alloc_io_memory(_fb_size)), _pixels(_env.rm().attach(_fb_ds)), - _surface(reinterpret_cast(_pixels), - Genode::Surface_base::Area(_fb_mode.width(), - _fb_mode.height())) + _surface(reinterpret_cast(_pixels), _fb_mode.area) { guest_memory.add_region(alloc, PHYS_FRAME_VGA << 12, _fb_vm_mapping, _fb_vm_ds, _fb_size); diff --git a/repos/ports/src/app/seoul/console.h b/repos/ports/src/app/seoul/console.h index 0fc5fa6fbe..dcab50bbf9 100644 --- a/repos/ports/src/app/seoul/console.h +++ b/repos/ports/src/app/seoul/console.h @@ -34,7 +34,7 @@ #include #include -#include +#include /* local includes */ #include "keyboard.h" @@ -43,7 +43,7 @@ namespace Seoul { class Console; - using Genode::Pixel_rgb565; + using Genode::Pixel_rgb888; using Genode::Dataspace_capability; } @@ -64,7 +64,7 @@ class Seoul::Console : public StaticReceiver Genode::addr_t const _fb_vm_mapping; Genode::addr_t const _vm_phys_fb; short *_pixels; - Genode::Surface _surface; + Genode::Surface _surface; unsigned _timer { 0 }; Keyboard _vkeyb { _motherboard }; char *_guest_fb { nullptr }; diff --git a/repos/ports/src/virtualbox5/frontend/fb.h b/repos/ports/src/virtualbox5/frontend/fb.h index aa4a96fcc4..5a8bc15c3e 100644 --- a/repos/ports/src/virtualbox5/frontend/fb.h +++ b/repos/ports/src/virtualbox5/frontend/fb.h @@ -17,9 +17,8 @@ #include #undef Framebuffer -#include #include -#include +#include /* VirtualBox includes */ @@ -37,7 +36,7 @@ class Genodefb : Gui::Connection &_gui; Fb_Genode::Session &_fb; View_handle _view; - Fb_Genode::Mode _fb_mode { 1024, 768, Fb_Genode::Mode::RGB565 }; + Fb_Genode::Mode _fb_mode { .area = { 1024, 768 } }; /* * The mode currently used by the VM. Can be smaller than the @@ -52,21 +51,19 @@ class Genodefb : { if (!_fb_base) return; - size_t const max_h = Genode::min(_fb_mode.height(), _virtual_fb_mode.height()); - size_t const num_pixels = _fb_mode.width() * max_h; + size_t const max_h = Genode::min(_fb_mode.area.h(), _virtual_fb_mode.area.h()); + size_t const num_pixels = _fb_mode.area.w() * max_h; memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel()); - _fb.refresh(0, 0, _virtual_fb_mode.width(), _virtual_fb_mode.height()); + _fb.refresh(0, 0, _virtual_fb_mode.area.w(), _virtual_fb_mode.area.h()); } void _adjust_buffer() { - _gui.buffer(Fb_Genode::Mode(_fb_mode.width(), _fb_mode.height(), - Fb_Genode::Mode::RGB565), false); + _gui.buffer(_fb_mode, false); typedef Gui::Session::Command Command; - Gui::Rect rect(Gui::Point(0, 0), - Gui::Area(_fb_mode.width(), _fb_mode.height())); + Gui::Rect rect(Gui::Point(0, 0), _fb_mode.area); _gui.enqueue(_view, rect); _gui.execute(); @@ -100,8 +97,8 @@ class Genodefb : Assert(rc == VINF_SUCCESS); } - int w() const { return _fb_mode.width(); } - int h() const { return _fb_mode.height(); } + int w() const { return _fb_mode.area.w(); } + int h() const { return _fb_mode.area.h(); } void update_mode(Fb_Genode::Mode mode) { @@ -140,33 +137,29 @@ class Genodefb : Lock(); - bool ok = (w <= (ULONG)_fb_mode.width()) && - (h <= (ULONG)_fb_mode.height()); + bool ok = (w <= (ULONG)_fb_mode.area.w()) && + (h <= (ULONG)_fb_mode.area.h()); if (ok) { Genode::log("fb resize : [", screen, "] ", - _virtual_fb_mode.width(), "x", - _virtual_fb_mode.height(), " -> ", + _virtual_fb_mode.area, " -> ", w, "x", h, - " (host: ", _fb_mode.width(), "x", - _fb_mode.height(), ")"); + " (host: ", _fb_mode.area, ")"); - if ((w < (ULONG)_fb_mode.width()) || - (h < (ULONG)_fb_mode.height())) { + if ((w < (ULONG)_fb_mode.area.w()) || + (h < (ULONG)_fb_mode.area.h())) { /* clear the old content around the new, smaller area. */ _clear_screen(); } - _virtual_fb_mode = Fb_Genode::Mode(w, h, Fb_Genode::Mode::RGB565); + _virtual_fb_mode = Fb_Genode::Mode { .area = { w, h } }; result = S_OK; } else Genode::log("fb resize : [", screen, "] ", - _virtual_fb_mode.width(), "x", - _virtual_fb_mode.height(), " -> ", + _virtual_fb_mode.area, " -> ", w, "x", h, " ignored" - " (host: ", _fb_mode.width(), "x", - _fb_mode.height(), ")"); + " (host: ", _fb_mode.area, ")"); Unlock(); @@ -205,19 +198,23 @@ class Genodefb : Lock(); - Gui::Area const area_fb = Gui::Area(_fb_mode.width(), - _fb_mode.height()); + Gui::Area const area_fb = _fb_mode.area; Gui::Area const area_vm = Gui::Area(width, height); using namespace Genode; typedef Pixel_rgb888 Pixel_src; - typedef Pixel_rgb565 Pixel_dst; + typedef Pixel_rgb888 Pixel_dst; Texture texture((Pixel_src *)image, nullptr, area_vm); Surface surface((Pixel_dst *)_fb_base, area_fb); - Dither_painter::paint(surface, texture, Surface_base::Point(o_x, o_y)); + Texture_painter::paint(surface, + texture, + Genode::Color(0, 0, 0), + Gui::Point(o_x, o_y), + Texture_painter::SOLID, + false); _fb.refresh(o_x, o_y, area_vm.w(), area_vm.h()); @@ -240,8 +237,8 @@ class Genodefb : if (!supported) return E_POINTER; - *supported = ((width <= (ULONG)_fb_mode.width()) && - (height <= (ULONG)_fb_mode.height())); + *supported = ((width <= (ULONG)_fb_mode.area.w()) && + (height <= (ULONG)_fb_mode.area.h())); return S_OK; } diff --git a/repos/ports/src/virtualbox5/nova/target.mk b/repos/ports/src/virtualbox5/nova/target.mk index acd5ca199c..046bda250e 100644 --- a/repos/ports/src/virtualbox5/nova/target.mk +++ b/repos/ports/src/virtualbox5/nova/target.mk @@ -2,6 +2,7 @@ TARGET = virtualbox5-nova REQUIRES = nova LIBS += virtualbox5-nova +LIBS += blit include $(REP_DIR)/src/virtualbox5/target.inc diff --git a/repos/ports/src/virtualbox5/target.mk b/repos/ports/src/virtualbox5/target.mk index e191b5d88c..f7bd54b51f 100644 --- a/repos/ports/src/virtualbox5/target.mk +++ b/repos/ports/src/virtualbox5/target.mk @@ -3,6 +3,7 @@ TARGET = virtualbox5 include $(REP_DIR)/src/virtualbox5/target.inc LIBS += virtualbox5 +LIBS += blit vpath frontend/% $(REP_DIR)/src/virtualbox5/ vpath %.cc $(REP_DIR)/src/virtualbox5/