diff --git a/run/dosbox.run b/run/dosbox.run
index 8f1cc55..ba29bde 100644
--- a/run/dosbox.run
+++ b/run/dosbox.run
@@ -33,7 +33,7 @@ install_config {
-
+
diff --git a/run/entropy_view.run b/run/entropy_view.run
index b134df2..0fbcd97 100644
--- a/run/entropy_view.run
+++ b/run/entropy_view.run
@@ -32,8 +32,8 @@ append config {
-
-
+
+
diff --git a/run/flif.run b/run/flif.run
index 7cb821a..e98ae14 100644
--- a/run/flif.run
+++ b/run/flif.run
@@ -37,8 +37,8 @@ install_config {
-
-
+
+
diff --git a/run/gui_app.inc b/run/gui_app.inc
index 8e87d95..a9b07e4 100644
--- a/run/gui_app.inc
+++ b/run/gui_app.inc
@@ -48,8 +48,8 @@ install_config {
-
-
+
+
diff --git a/run/julia_fractal.run b/run/julia_fractal.run
index c5f5824..32597d8 100644
--- a/run/julia_fractal.run
+++ b/run/julia_fractal.run
@@ -1,6 +1,6 @@
set app_config {
-
+
diff --git a/src/app/entropy_view/main.cc b/src/app/entropy_view/main.cc
index d8d95ab..7b424e3 100644
--- a/src/app/entropy_view/main.cc
+++ b/src/app/entropy_view/main.cc
@@ -48,7 +48,7 @@ struct Entropy_view::Main
Dataspace_capability _fb_ds_cap()
{
using Framebuffer::Mode;
- Mode mode(WIDTH, HEIGHT, Mode::RGB565);
+ Mode mode { .area = { WIDTH, HEIGHT } };
_gui.buffer(mode, false);
return _fb.dataspace();
}
@@ -61,7 +61,7 @@ struct Entropy_view::Main
void _plot()
{
- uint16_t *pixels = _fb_ds.local_addr();
+ uint32_t *pixels = _fb_ds.local_addr();
static uint8_t buf[HEIGHT];
size_t n = _entropy.read(buf, sizeof(buf));
if (n != sizeof(buf)) {
@@ -69,7 +69,7 @@ struct Entropy_view::Main
}
for (int i = 0; i < HEIGHT; ++i) {
- uint16_t *row = &pixels[i*WIDTH];
+ uint32_t *row = &pixels[i*WIDTH];
row[buf[i]] = ~row[buf[i]];
}
diff --git a/src/app/flif_view/flif_view.cc b/src/app/flif_view/flif_view.cc
index 31197d8..317f4f5 100644
--- a/src/app/flif_view/flif_view.cc
+++ b/src/app/flif_view/flif_view.cc
@@ -25,7 +25,7 @@
#include
#include
#include
-#include
+#include
/* gems includes */
#include
@@ -76,51 +76,47 @@ struct Flif_view::Main
/* signal transmitter to wake application from input handling */
Signal_transmitter app_transmitter { app_handler };
- Mode nit_mode = gui.mode();
+ Mode gui_mode = gui.mode();
Surface_base::Area img_area { };
Constructible nit_ds { };
template
- void apply_to_texture(int width, int height, FN const &fn)
+ void apply_to_texture(unsigned width, unsigned height, FN const &fn)
{
- if (nit_mode.width() < width || nit_mode.height() < height) {
- Mode new_mode(max(nit_mode.width(), width),
- max(nit_mode.height(), height),
- Mode::RGB565);
+ if (gui_mode.area.w() < width || gui_mode.area.h() < height) {
+ Mode new_mode { .area = { max(gui_mode.area.w(), width),
+ max(gui_mode.area.h(), height) } };
Genode::log("resize gui buffer to ", new_mode);
if (nit_ds.constructed())
nit_ds.destruct();
gui.buffer(new_mode, false);
nit_ds.construct(env.rm(), gui.framebuffer()->dataspace());
- nit_mode = gui.mode();
+ gui_mode = gui.mode();
Genode::log("rebuffering complete");
} else if (!nit_ds.constructed()) {
- gui.buffer(nit_mode, false);
+ gui.buffer(gui_mode, false);
nit_ds.construct(env.rm(), gui.framebuffer()->dataspace());
}
Genode::size_t const buffer_size =
- nit_mode.height() * nit_mode.width() * nit_mode.bytes_per_pixel();
+ gui_mode.area.count() * gui_mode.bytes_per_pixel();
if (buffer_size > back_ds.size())
back_ds.realloc(&env.pd(), buffer_size);
- Surface_base::Area nit_area(nit_mode.width(), nit_mode.height());
- Texture texture(back_ds.local_addr(), nullptr, nit_area);
+ Texture texture(back_ds.local_addr(), nullptr, gui_mode.area);
fn(texture);
}
void handle_sync_signal()
{
- typedef Pixel_rgb565 PT;
+ typedef Pixel_rgb888 PT;
- Surface_base::Area nit_area(nit_mode.width(), nit_mode.height());
-
- Texture texture(back_ds.local_addr(), nullptr, nit_area);
- Surface surface(nit_ds->local_addr(), nit_area);
+ Texture texture(back_ds.local_addr(), nullptr, gui_mode.area);
+ Surface surface(nit_ds->local_addr(), gui_mode.area);
Texture_painter::paint(
surface, texture, Color(), Surface_base::Point(),
@@ -297,7 +293,7 @@ void Flif_view::Main::render(FLIF_IMAGE *img)
int const f_width = flif_image_get_width(img);
int const f_height = flif_image_get_height(img);
- typedef Pixel_rgb565 PT;
+ typedef Pixel_rgb888 PT;
apply_to_texture(f_width, f_height, [&] (Texture &texture) {
/* fill texture with FLIF image data */
char row[f_width*4];
@@ -326,7 +322,7 @@ bool Flif_view::Main::render_page()
}
flif_dec = flif_create_decoder();
- flif_decoder_set_resize(flif_dec, nit_mode.width(), nit_mode.height());
+ flif_decoder_set_resize(flif_dec, gui_mode.area.w(), gui_mode.area.h());
flif_decoder_set_callback(flif_dec, &(progressive_render), this);
gui.enqueue(view_handle, filename);
diff --git a/src/app/julia_fractal/main.cc b/src/app/julia_fractal/main.cc
index 42836f3..441b521 100644
--- a/src/app/julia_fractal/main.cc
+++ b/src/app/julia_fractal/main.cc
@@ -36,7 +36,7 @@
#include
#include
-#include
+#include
#include
#include
#include
@@ -45,7 +45,7 @@
struct Painter_T {
virtual ~Painter_T() = default;
- virtual void paint(Genode::Pixel_rgb565*, unsigned w, unsigned h) = 0;
+ virtual void paint(Genode::Pixel_rgb888*, unsigned w, unsigned h) = 0;
};
class window {
@@ -60,10 +60,10 @@ class window {
View_handle _view{};
void _draw_frame() {
- _draw.paint(_ds->local_addr(), _mode.width(), _mode.height()); }
+ _draw.paint(_ds->local_addr(), _mode.area.w(), _mode.area.h()); }
void _refresh() {
- _npconn.framebuffer()->refresh(0, 0, _mode.width(), _mode.height()); }
+ _npconn.framebuffer()->refresh(0, 0, _mode.area.w(), _mode.area.h()); }
void _new_mode() {
_mode = _npconn.mode();
@@ -72,9 +72,7 @@ class window {
_draw_frame();
_refresh();
- auto rect = Gui::Rect{Gui::Point{0, 0},
- Gui::Area{(unsigned)_mode.width(),
- (unsigned)_mode.height()}};
+ auto rect = Gui::Rect{Gui::Point{0, 0}, _mode.area};
_npconn.enqueue(_view, rect);
_npconn.execute();
}
@@ -88,7 +86,7 @@ public:
window(Genode::Env& env, Painter_T& painter,
Title_String_T title, Gui::Area wsize)
: _env{env}, _npconn{env},
- _mode{(int)wsize.w(), (int)wsize.h(), Framebuffer::Mode::RGB565},
+ _mode{ .area = wsize },
_draw{painter}
{
using Gui::Session;
@@ -126,7 +124,7 @@ public:
/**
* Draw a calculated set in the buffer.
*/
- void paint(Genode::Pixel_rgb565* buf, unsigned w, unsigned h) override
+ void paint(Genode::Pixel_rgb888* buf, unsigned w, unsigned h) override
{
--w, --h;
const auto _w = w;
diff --git a/src/app/qt_avplay/gui_session_component.h b/src/app/qt_avplay/gui_session_component.h
index d72acb6..3f465c7 100644
--- a/src/app/qt_avplay/gui_session_component.h
+++ b/src/app/qt_avplay/gui_session_component.h
@@ -133,12 +133,12 @@ struct Gui::Session_component : Rpc_object
{
Framebuffer::Mode connection_mode { _connection.mode() };
Framebuffer::Mode new_mode {
- Genode::min(connection_mode.width(),
- _genode_view_widget.maximumWidth()),
- Genode::min(connection_mode.height(),
- _genode_view_widget.maximumHeight()),
- connection_mode.format()
- };
+ .area = {
+ Genode::min(connection_mode.area.w(),
+ (unsigned)_genode_view_widget.maximumWidth()),
+ Genode::min(connection_mode.area.h(),
+ (unsigned)_genode_view_widget.maximumHeight())
+ }};
return new_mode;
}
diff --git a/src/app/show_input/main.cc b/src/app/show_input/main.cc
index 1b773c4..6199485 100644
--- a/src/app/show_input/main.cc
+++ b/src/app/show_input/main.cc
@@ -18,7 +18,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -64,9 +64,9 @@ struct Show_input::Main
Gui::Session::View_handle _view = _gui.create_view();
- typedef Pixel_rgb565 PT;
+ typedef Pixel_rgb888 PT;
- Surface_base::Area _size { (unsigned)_fb.mode().width(),
+ Surface_base::Area _size { _fb.mode().area.w(),
(unsigned)_font.height() };
Surface _surface { _fb_ds.local_addr(), _size };
diff --git a/src/drivers/framebuffer/spec/exynos5/driver.cc b/src/drivers/framebuffer/spec/exynos5/driver.cc
index 69ac970..62fba90 100644
--- a/src/drivers/framebuffer/spec/exynos5/driver.cc
+++ b/src/drivers/framebuffer/spec/exynos5/driver.cc
@@ -372,8 +372,6 @@ class Video_mixer : public Attached_mmio
public:
- typedef Framebuffer::Driver::Format Format;
-
/**
* Constructor
*/
@@ -386,13 +384,11 @@ class Video_mixer : public Attached_mmio
* \param fb_phys physical base of framebuffer
* \param fb_width width of framebuffer in pixel
* \param fb_height height of framebuffer in pixel
- * \param fb_format pixel format of framebuffer
*
* \retval 0 succeeded
* \retval -1 failed
*/
- int init(addr_t const fb_phys, size_t const fb_width,
- size_t const fb_height, Format const fb_format)
+ int init(addr_t const fb_phys, size_t const fb_width, size_t const fb_height)
{
using namespace Framebuffer;
@@ -439,14 +435,8 @@ class Video_mixer : public Attached_mmio
write(gcfg);
/* input pixel format */
- switch (fb_format) {
- case Driver::FORMAT_RGB565:
- write(4);
- break;
- default:
- error("framebuffer format not supported");
- return -1;
- }
+ write(7);
+
/* window measurements */
write(fb_width);
M0_g0_wh::access_t wh = read();
@@ -1082,12 +1072,10 @@ class Hdmi : public Attached_mmio
** Framebuffer::Driver **
*************************/
-int Framebuffer::Driver::init(size_t width, size_t height, Format format,
- addr_t fb_phys)
+int Framebuffer::Driver::init(size_t width, size_t height, addr_t fb_phys)
{
_fb_width = width;
_fb_height = height;
- _fb_format = format;
static Timer_delayer delayer(_env);
@@ -1101,7 +1089,7 @@ int Framebuffer::Driver::init(size_t width, size_t height, Format format,
/* set-up video mixer to feed HDMI */
static Video_mixer video_mixer(_env);
- err = video_mixer.init(fb_phys, _fb_width, _fb_height, _fb_format);
+ err = video_mixer.init(fb_phys, _fb_width, _fb_height);
if (err) { return -1; }
/* set-up HDMI to feed connected device */
diff --git a/src/drivers/framebuffer/spec/exynos5/driver.h b/src/drivers/framebuffer/spec/exynos5/driver.h
index 3c0308b..e5fdc2f 100644
--- a/src/drivers/framebuffer/spec/exynos5/driver.h
+++ b/src/drivers/framebuffer/spec/exynos5/driver.h
@@ -33,7 +33,6 @@ class Framebuffer::Driver
{
public:
- enum Format { FORMAT_RGB565 };
enum Output { OUTPUT_LCD, OUTPUT_HDMI };
private:
@@ -42,7 +41,6 @@ class Framebuffer::Driver
size_t _fb_width;
size_t _fb_height;
- Format _fb_format;
public:
@@ -53,27 +51,15 @@ class Framebuffer::Driver
:
_env(env),
_fb_width(0),
- _fb_height(0),
- _fb_format(FORMAT_RGB565)
+ _fb_height(0)
{ }
/**
- * Return amount of bytes that is used for one pixel descriptor
- *
- * \param format pixel format
- *
- * \retval 0 failed
- * \retval >0 succeeded
+ * Return amount of bytes that is used for one pixel
*/
- static size_t bytes_per_pixel(Format format)
+ static size_t bytes_per_pixel()
{
- switch (format) {
- case FORMAT_RGB565:
- return 2;
- default:
- error("unknown pixel format");
- return 0;
- }
+ return 4; /* 32-bit RGB */
}
/**
@@ -81,14 +67,13 @@ class Framebuffer::Driver
*
* \param width width of framebuffer in pixel
* \param height height of framebuffer in pixel
- * \param format pixel format of framebuffer
*
* \retval 0 failed
* \retval >0 succeeded
*/
- size_t buffer_size(size_t width, size_t height, Format format)
+ size_t buffer_size(size_t width, size_t height)
{
- return bytes_per_pixel(format) * width * height;
+ return bytes_per_pixel() * width * height;
}
/**
@@ -96,13 +81,12 @@ class Framebuffer::Driver
*
* \param width width of screen and framebuffer in pixel
* \param height height of screen and framebuffer in pixel
- * \param format pixel format of framebuffer
* \param fb_phys physical base of framebuffer
*
* \retval -1 failed
* \retval 0 succeeded
*/
- int init(size_t width, size_t height, Format format, addr_t fb_phys);
+ int init(size_t width, size_t height, addr_t fb_phys);
};
#endif /* _DRIVER_H_ */
diff --git a/src/drivers/framebuffer/spec/exynos5/main.cc b/src/drivers/framebuffer/spec/exynos5/main.cc
index db547e6..6175ed9 100644
--- a/src/drivers/framebuffer/spec/exynos5/main.cc
+++ b/src/drivers/framebuffer/spec/exynos5/main.cc
@@ -43,24 +43,12 @@ class Framebuffer::Session_component
Genode::Env &_env;
- unsigned _width;
- unsigned _height;
- Driver::Format _format;
- size_t _size;
- Dataspace_capability _ds;
- addr_t _phys_base;
- Timer::Connection _timer { _env };
-
- /**
- * Convert Driver::Format to Framebuffer::Mode::Format
- */
- static Mode::Format _convert_format(Driver::Format driver_format)
- {
- switch (driver_format) {
- case Driver::FORMAT_RGB565: return Mode::RGB565;
- }
- return Mode::INVALID;
- }
+ unsigned _width;
+ unsigned _height;
+ size_t _size;
+ Dataspace_capability _ds;
+ addr_t _phys_base;
+ Timer::Connection _timer { _env };
public:
@@ -78,12 +66,11 @@ class Framebuffer::Session_component
_env(env),
_width(width),
_height(height),
- _format(Driver::FORMAT_RGB565),
- _size(driver.buffer_size(width, height, _format)),
+ _size(driver.buffer_size(width, height)),
_ds(_env.ram().alloc(_size, WRITE_COMBINED)),
_phys_base(Dataspace_client(_ds).phys_addr())
{
- if (driver.init(width, height, _format, _phys_base)) {
+ if (driver.init(width, height, _phys_base)) {
error("could not initialize display");
struct Could_not_initialize_display : Exception { };
throw Could_not_initialize_display();
@@ -98,7 +85,7 @@ class Framebuffer::Session_component
Mode mode() const override
{
- return Mode(_width, _height, _convert_format(_format));
+ return Mode { .area = { _width, _height } };
}
void mode_sigh(Genode::Signal_context_capability) override { }
diff --git a/src/drivers/framebuffer/spec/omap4/driver.h b/src/drivers/framebuffer/spec/omap4/driver.h
index 93604de..c11f7ad 100644
--- a/src/drivers/framebuffer/spec/omap4/driver.h
+++ b/src/drivers/framebuffer/spec/omap4/driver.h
@@ -33,7 +33,6 @@ class Framebuffer::Driver
{
public:
- enum Format { FORMAT_RGB565 };
enum Output { OUTPUT_LCD, OUTPUT_HDMI };
private:
@@ -80,27 +79,19 @@ class Framebuffer::Driver
size_t _fb_width;
size_t _fb_height;
- Format _fb_format;
public:
Driver(Genode::Env &env);
- static size_t bytes_per_pixel(Format format)
+ static size_t bytes_per_pixel() { return 4; /* 32-bit RGB */ }
+
+ size_t buffer_size(size_t width, size_t height)
{
- switch (format) {
- case FORMAT_RGB565: return 2;
- }
- return 0;
+ return bytes_per_pixel()*width*height;
}
- size_t buffer_size(size_t width, size_t height, Format format)
- {
- return bytes_per_pixel(format)*width*height;
- }
-
- bool init(size_t width, size_t height, Format format,
- Output output, addr_t phys_base);
+ bool init(size_t width, size_t height, Output output, addr_t phys_base);
};
@@ -117,8 +108,7 @@ Framebuffer::Driver::Driver(Genode::Env &env)
_hdmi((addr_t)_hdmi_mmio.local_addr()),
_fb_width(0),
- _fb_height(0),
- _fb_format(FORMAT_RGB565)
+ _fb_height(0)
{ }
@@ -133,11 +123,7 @@ bool Framebuffer::Driver::_init_lcd(Framebuffer::addr_t phys_base)
_dispc.write(_fb_width - 1);
_dispc.write(_fb_height - 1);
- Dispc::Gfx_attributes::access_t pixel_format = 0;
- switch (_fb_format) {
- case FORMAT_RGB565: pixel_format = Dispc::Gfx_attributes::Format::RGB16; break;
- }
- _dispc.write(pixel_format);
+ _dispc.write(Dispc::Gfx_attributes::Format::ARGB32);
_dispc.write(phys_base);
_dispc.write(phys_base);
@@ -237,11 +223,7 @@ bool Framebuffer::Driver::_init_hdmi(Framebuffer::addr_t phys_base)
_hdmi.write(1);
- Dispc::Gfx_attributes::access_t pixel_format = 0;
- switch (_fb_format) {
- case FORMAT_RGB565: pixel_format = Dispc::Gfx_attributes::Format::RGB16; break;
- }
- _dispc.write(pixel_format);
+ _dispc.write(Dispc::Gfx_attributes::Format::ARGB32);
_dispc.write(phys_base);
_dispc.write(phys_base);
@@ -270,13 +252,10 @@ bool Framebuffer::Driver::_init_hdmi(Framebuffer::addr_t phys_base)
bool Framebuffer::Driver::init(size_t width, size_t height,
- Framebuffer::Driver::Format format,
- Output output,
- Framebuffer::addr_t phys_base)
+ Output output, Framebuffer::addr_t phys_base)
{
_fb_width = width;
_fb_height = height;
- _fb_format = format;
bool ret = false;
switch (output) {
diff --git a/src/drivers/framebuffer/spec/omap4/main.cc b/src/drivers/framebuffer/spec/omap4/main.cc
index ccd571c..1f16dec 100644
--- a/src/drivers/framebuffer/spec/omap4/main.cc
+++ b/src/drivers/framebuffer/spec/omap4/main.cc
@@ -41,12 +41,11 @@ class Framebuffer::Session_component : public Genode::Rpc_object x2 || y1 > y2) return;
@@ -85,10 +73,10 @@ class Framebuffer::Session_component : public Genode::Rpc_object output;
- node.attribute("output").value(&output);
-
- if (output == "LCD") { value = Framebuffer::Driver::OUTPUT_LCD; }
- } catch (...) { }
+ if (node.attribute_value("output", Genode::String<8>()) == "LDC")
+ value = Framebuffer::Driver::OUTPUT_LCD;
return value;
}
diff --git a/src/lib/sdl/video/SDL_genode_fb_video.cc b/src/lib/sdl/video/SDL_genode_fb_video.cc
index 9eea870..0e2bd02 100644
--- a/src/lib/sdl/video/SDL_genode_fb_video.cc
+++ b/src/lib/sdl/video/SDL_genode_fb_video.cc
@@ -71,12 +71,12 @@ extern "C" {
Genode::Lock_guard guard(event_lock);
Framebuffer::Mode mode = _gui.mode();
- df_mode.w = mode.width();
- df_mode.h = mode.height();
+ df_mode.w = mode.area.w();
+ df_mode.h = mode.area.h();
video_events.resize_pending = true;
- video_events.width = mode.width();
- video_events.height = mode.height();
+ video_events.width = mode.area.w();
+ video_events.height = mode.area.h();
}
Genode::Signal_handler _mode_handler {
@@ -98,18 +98,16 @@ extern "C" {
** Framebuffer::Session Interface **
************************************/
- Genode::Dataspace_capability dataspace(int width, int height)
+ Genode::Dataspace_capability dataspace(unsigned width, unsigned height)
{
- _gui.buffer(
- ::Framebuffer::Mode(width, height, Framebuffer::Mode::RGB565),
- false);
+ _gui.buffer(::Framebuffer::Mode { .area = { width, height } }, false);
::Framebuffer::Mode mode = _gui.framebuffer()->mode();
using namespace Gui;
Area area(
- Genode::min(mode.width(), width),
- Genode::min(mode.height(), height));
+ Genode::min(mode.area.w(), width),
+ Genode::min(mode.area.h(), height));
typedef Gui::Session::Command Command;
_gui.enqueue(
@@ -271,7 +269,7 @@ extern "C" {
return false;
}
- Genode_egl_window egl_window { scr_mode.width(), scr_mode.height(),
+ Genode_egl_window egl_window { (int)scr_mode.area.w(), (int)scr_mode.area.h(),
(unsigned char*)t->hidden->buffer };
screen_surf = __eglCreatePixmapSurface(display, config, &egl_window, NULL);
@@ -395,31 +393,21 @@ extern "C" {
/* Get the framebuffer size and mode infos */
scr_mode = framebuffer->mode();
- t->info.current_w = scr_mode.width();
- t->info.current_h = scr_mode.height();
+ t->info.current_w = scr_mode.area.w();
+ t->info.current_h = scr_mode.area.h();
Genode::log("Framebuffer has "
"width=", t->info.current_w, " "
"height=", t->info.current_h);
/* set mode specific values */
- switch(scr_mode.format())
- {
- case Framebuffer::Mode::RGB565:
- Genode::log("We use pixelformat rgb565.");
- vformat->BitsPerPixel = 16;
- vformat->BytesPerPixel = scr_mode.bytes_per_pixel();
- vformat->Rmask = 0x0000f800;
- vformat->Gmask = 0x000007e0;
- vformat->Bmask = 0x0000001f;
- break;
- default:
- SDL_SetError("Couldn't get console mode info");
- Genode_Fb_VideoQuit(t);
- return -1;
- }
+ vformat->BitsPerPixel = 32;
+ vformat->BytesPerPixel = scr_mode.bytes_per_pixel();
+ vformat->Rmask = 0x00ff0000;
+ vformat->Gmask = 0x0000ff00;
+ vformat->Bmask = 0x000000ff;
modes[0] = &df_mode;
- df_mode.w = scr_mode.width();
- df_mode.h = scr_mode.height();
+ df_mode.w = scr_mode.area.w();
+ df_mode.h = scr_mode.area.h();
modes[1] = 0;
t->hidden->buffer = 0;
@@ -447,13 +435,13 @@ extern "C" {
/**
- * Any mode is okay if the pixel format is 16bit
+ * Any mode is okay if the pixel format is 32 bit
*/
SDL_Rect **Genode_Fb_ListModes(SDL_VideoDevice *t,
SDL_PixelFormat *format,
Uint32 flags)
{
- return (SDL_Rect **)((format->BitsPerPixel == 16) ? -1 : 0);
+ return (SDL_Rect **)((format->BitsPerPixel == 32) ? -1 : 0);
}
@@ -611,7 +599,7 @@ extern "C" {
#if defined(SDL_VIDEO_OPENGL)
__eglWaitClient();
__eglSwapBuffers(display, screen_surf);
- framebuffer->refresh(0, 0, scr_mode.width(), scr_mode.height());
+ framebuffer->refresh(0, 0, scr_mode.area.w(), scr_mode.area.h());
#endif
}
diff --git a/src/lib/sdl2/video/SDL_genode_fb_video.cc b/src/lib/sdl2/video/SDL_genode_fb_video.cc
index fac88a0..e2bcc12 100644
--- a/src/lib/sdl2/video/SDL_genode_fb_video.cc
+++ b/src/lib/sdl2/video/SDL_genode_fb_video.cc
@@ -74,8 +74,8 @@ extern "C" {
Framebuffer::Mode mode = _gui.mode();
video_events.resize_pending = true;
- video_events.width = mode.width();
- video_events.height = mode.height();
+ video_events.width = mode.area.w();
+ video_events.height = mode.area.h();
}
Genode::Signal_handler _mode_handler {
@@ -104,18 +104,16 @@ extern "C" {
** Framebuffer::Session Interface **
************************************/
- Genode::Dataspace_capability dataspace(int width, int height)
+ Genode::Dataspace_capability dataspace(unsigned width, unsigned height)
{
- _gui.buffer(
- ::Framebuffer::Mode(width, height, Framebuffer::Mode::RGB565),
- false);
+ _gui.buffer(::Framebuffer::Mode { .area = { width, height } }, false);
::Framebuffer::Mode mode = _gui.framebuffer()->mode();
using namespace Gui;
Area area(
- Genode::min(mode.width(), width),
- Genode::min(mode.height(), height));
+ Genode::min(mode.area.w(), width),
+ Genode::min(mode.area.h(), height));
typedef Gui::Session::Command Command;
_gui.enqueue(
@@ -180,7 +178,7 @@ extern "C" {
Genode_Driverdata &drv = *(Genode_Driverdata *)device->driverdata;
- Uint32 const surface_format = SDL_PIXELFORMAT_RGB565;
+ Uint32 const surface_format = SDL_PIXELFORMAT_ABGR8888;
/* Free the old surface */
SDL_Surface *surface = (SDL_Surface *)SDL_GetWindowData(window,
@@ -191,7 +189,7 @@ extern "C" {
surface = NULL;
}
- /* get 16bit RGB mask values */
+ /* get 32-bit RGB mask values */
int bpp;
Uint32 r_mask, g_mask, b_mask, a_mask;
if (!SDL_PixelFormatEnumToMasks(surface_format, &bpp, &r_mask, &g_mask,
@@ -299,37 +297,24 @@ extern "C" {
drv.scr_mode = drv.framebuffer->mode();
/* set mode specific values */
- switch(drv.scr_mode.format()) {
- case Framebuffer::Mode::RGB565:
- {
- Genode::log("We use pixelformat rgb565.");
+ device->displays = (SDL_VideoDisplay *)(SDL_calloc(1, sizeof(*device->displays)));
+ if (!device->displays)
+ return SDL_SetError("Memory allocation failed");
- device->displays = (SDL_VideoDisplay *)(SDL_calloc(1, sizeof(*device->displays)));
- if (!device->displays)
- return SDL_SetError("Memory allocation failed");
+ SDL_DisplayMode mode {
+ .format = SDL_PIXELFORMAT_ABGR8888,
+ .w = drv.scr_mode.area.w(),
+ .h = drv.scr_mode.area.h(),
+ .refresh_rate = 0,
+ .driverdata = nullptr
+ };
- SDL_DisplayMode mode {
- .format = SDL_PIXELFORMAT_RGB565,
- .w = drv.scr_mode.width(),
- .h = drv.scr_mode.height(),
- .refresh_rate = 0,
- .driverdata = nullptr
- };
+ SDL_VideoDisplay &display = device->displays[0];
+ if (!SDL_AddDisplayMode(&display, &mode))
+ return SDL_SetError("Setting display mode failed");
- SDL_VideoDisplay &display = device->displays[0];
- if (!SDL_AddDisplayMode(&display, &mode))
- return SDL_SetError("Setting display mode failed");
-
- display.current_mode = mode;
- device->num_displays = 1;
-
- break;
- }
- default:
- SDL_SetError("Couldn't get console mode info");
- GenodeVideo_Quit(device);
- return -1;
- }
+ display.current_mode = mode;
+ device->num_displays = 1;
return 0;
}
diff --git a/src/server/fb_upscale/component.cc b/src/server/fb_upscale/component.cc
index 1d3b322..5c202a8 100644
--- a/src/server/fb_upscale/component.cc
+++ b/src/server/fb_upscale/component.cc
@@ -47,7 +47,7 @@ class Fb_scaler::Session_component : public Genode::Rpc_object _parent_ds;
@@ -72,21 +72,21 @@ class Fb_scaler::Session_component : public Genode::Rpc_objectlocal_addr();
for (int y = py; y < ph; ++y) {
- int src_y = ((y*_scale_ratio) >> SHIFT)*_client_mode.width();
+ int src_y = ((y*_scale_ratio) >> SHIFT)*_client_mode.area.w();
for (int x = px; x < pw; ++x) {
- dst[(_y_offset+y)*_parent_mode.width()+x+_x_offset] =
+ dst[(_y_offset+y)*_parent_mode.area.w()+x+_x_offset] =
src[src_y+((x*_scale_ratio) >> SHIFT)];
}
}
@@ -196,7 +196,7 @@ class Fb_scaler::Root_component : Root_component_base
unsigned height = Arg_string::find_arg(args, "fb_height").ulong_value(0);
return new (md_alloc())
- Session_component(_env, Mode(width, height, Mode::INVALID));
+ Session_component(_env, Mode { .area = { width, height } });
}
public:
diff --git a/src/server/flif_capture/main.cc b/src/server/flif_capture/main.cc
index 668a46b..64ecec0 100644
--- a/src/server/flif_capture/main.cc
+++ b/src/server/flif_capture/main.cc
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
namespace Flif_capture {
using namespace Genode;
@@ -122,31 +123,29 @@ class Flif_capture::Encoder
/* TODO: attach/detach each capture? */
Genode::Attached_dataspace fb_ds(_env.rm(), fb_cap);
- if ((mode.format() != Mode::RGB565)
- || (fb_ds.size() < (mode.width() * mode.height() * mode.bytes_per_pixel()))) {
+ if (fb_ds.size() < mode.area.count() * mode.bytes_per_pixel()) {
Genode::error("invalid framebuffer for capture");
return;
}
- RGBA row[mode.width()];
+ RGBA row[mode.area.w()];
- _image = flif_create_image(mode.width(), mode.height());
+ _image = flif_create_image(mode.area.w(), mode.area.h());
if (!_image) {
Genode::error("failed to create image buffer");
return;
}
- uint16_t const *pixels = fb_ds.local_addr();
+ using Pixel = Pixel_rgb888;
+ Pixel const *pixels = fb_ds.local_addr();
- for (int y = 0; y < mode.height(); y++) {
- for (int x = 0; x < mode.width(); x++) {
- uint16_t px = pixels[y*mode.width()+x];
- row[x] = RGBA {
- (uint8_t)((px & 0xf800) >> 8),
- (uint8_t)((px & 0x07e0) >> 3),
- (uint8_t)((px & 0x1f) << 3),
- (uint8_t)(0xff)
- };
+ for (unsigned y = 0; y < mode.area.h(); y++) {
+ for (unsigned x = 0; x < mode.area.w(); x++) {
+ Pixel const px = pixels[y*mode.area.w()+x];
+ row[x] = RGBA { (uint8_t)px.r(),
+ (uint8_t)px.g(),
+ (uint8_t)px.b(),
+ 255 };
}
flif_image_write_row_RGBA8(_image, y, row, sizeof(row));
}
@@ -238,7 +237,7 @@ class Flif_capture::Main
};
Flif_capture::Encoder _encoder { _env };
- Framebuffer::Connection _parent_fb { _env, Mode(0, 0, Mode::RGB565) };
+ Framebuffer::Connection _parent_fb { _env, Mode { } };
Input::Connection _parent_input { _env };
Framebuffer_session_component _fb_session {
diff --git a/src/test/sdl2/main.cc b/src/test/sdl2/main.cc
index 0810d62..6ae4656 100644
--- a/src/test/sdl2/main.cc
+++ b/src/test/sdl2/main.cc
@@ -41,7 +41,7 @@ static void draw(SDL_Surface * const screen, int w, int h, int v)
if (screen == nullptr) { return; }
/* paint something into pixel buffer */
- short* const pixels = (short*) screen->pixels;
+ Uint32* const pixels = (Uint32*) screen->pixels;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
pixels[i*w+j] = ((i+v)/32)*32*64 + ((j+v)/32)*32 + (i*j+v)/1024;