diff --git a/repos/gems/include/gems/xml_anchor.h b/repos/gems/include/gems/xml_anchor.h
index c5144981a5..e7d0e4a506 100644
--- a/repos/gems/include/gems/xml_anchor.h
+++ b/repos/gems/include/gems/xml_anchor.h
@@ -64,7 +64,7 @@ class Anchor
}
}
- PWRN("unsupported anchor attribute value");
+ Genode::warning("unsupported anchor attribute value");
}
};
diff --git a/repos/gems/src/app/backdrop/main.cc b/repos/gems/src/app/backdrop/main.cc
index 4eee4eae82..ba0d9d6049 100644
--- a/repos/gems/src/app/backdrop/main.cc
+++ b/repos/gems/src/app/backdrop/main.cc
@@ -12,14 +12,15 @@
*/
/* Genode includes */
+#include
+#include
+#include
#include
-#include
#include
-#include
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -30,15 +31,23 @@
#include
#include
-using namespace Genode;
+/* libc includes */
+#include
+using namespace Genode;
namespace Backdrop { struct Main; }
struct Backdrop::Main
{
- Nitpicker::Connection nitpicker;
+ Genode::Env &env;
+
+ Genode::Heap heap { env.ram(), env.rm() };
+
+ Genode::Attached_rom_dataspace config { env, "config" };
+
+ Nitpicker::Connection nitpicker { env, "backdrop" };
struct Buffer
{
@@ -56,26 +65,30 @@ struct Backdrop::Main
nitpicker.buffer(mode, false);
if (mode.format() != Framebuffer::Mode::RGB565) {
- PWRN("Color mode %d not supported\n", (int)mode.format());
+ Genode::warning("Color mode %d not supported\n", (int)mode.format());
return Dataspace_capability();
}
return nitpicker.framebuffer()->dataspace();
}
- Attached_dataspace fb_ds { _ds_cap(nitpicker) };
+ Attached_dataspace fb_ds;
Genode::size_t surface_num_bytes() const
{
return size().count()*mode.bytes_per_pixel();
}
- Attached_ram_dataspace surface_ds { env()->ram_session(), surface_num_bytes() };
+ Attached_ram_dataspace surface_ds;
/**
* Constructor
*/
- Buffer(Nitpicker::Connection &nitpicker) : nitpicker(nitpicker) { }
+ Buffer(Genode::Env &env, Nitpicker::Connection &nitpicker)
+ : nitpicker(nitpicker),
+ fb_ds(env.rm(), _ds_cap(nitpicker)),
+ surface_ds(env.ram(), env.rm(), surface_num_bytes())
+ { }
/**
* Return size of virtual framebuffer
@@ -117,20 +130,18 @@ struct Backdrop::Main
nitpicker.execute();
}
- Signal_receiver &sig_rec;
-
/**
* Function called on config change or mode change
*/
- void handle_config(unsigned);
+ void handle_config();
- Signal_dispatcher config_dispatcher = {
- sig_rec, *this, &Main::handle_config};
+ Signal_handler config_dispatcher = {
+ env.ep(), *this, &Main::handle_config };
- void handle_sync(unsigned);
+ void handle_sync();
- Signal_dispatcher sync_dispatcher = {
- sig_rec, *this, &Main::handle_sync};
+ Signal_handler sync_handler = {
+ env.ep(), *this, &Main::handle_sync};
template
void paint_texture(Surface &, Texture const &, Surface_base::Point, bool);
@@ -138,14 +149,13 @@ struct Backdrop::Main
void apply_image(Xml_node);
void apply_fill(Xml_node);
- Main(Signal_receiver &sig_rec) : sig_rec(sig_rec)
+ Main(Genode::Env &env) : env(env)
{
- /* trigger application of initial config */
- Signal_transmitter(config_dispatcher).submit();
-
nitpicker.mode_sigh(config_dispatcher);
- config()->sigh(config_dispatcher);
+ config.sigh(config_dispatcher);
+
+ handle_config();
}
};
@@ -222,7 +232,7 @@ void Backdrop::Main::apply_image(Xml_node operation)
typedef Surface_base::Area Area;
if (!operation.has_attribute("png")) {
- PWRN("missing 'png' attribute in node");
+ Genode::warning("missing 'png' attribute in node");
return;
}
@@ -230,7 +240,7 @@ void Backdrop::Main::apply_image(Xml_node operation)
png_file_name[0] = 0;
operation.attribute("png").value(png_file_name, sizeof(png_file_name));
- File file(png_file_name, *env()->heap());
+ File file(png_file_name, heap);
Anchor anchor(operation);
@@ -267,7 +277,7 @@ void Backdrop::Main::apply_image(Xml_node operation)
Texture *png_texture = png_image.texture();
/* create texture with the scaled image */
- Chunky_texture scaled_texture(*env()->ram_session(), scaled_size);
+ Chunky_texture scaled_texture(env.ram(), scaled_size);
scale(*png_texture, scaled_texture);
png_image.release_texture(png_texture);
@@ -278,7 +288,7 @@ void Backdrop::Main::apply_image(Xml_node operation)
/* create texture with down-sampled scaled image */
typedef Pixel_rgb565 PT;
- Chunky_texture texture(*env()->ram_session(), scaled_size);
+ Chunky_texture texture(env.ram(), scaled_size);
convert_pixel_format(scaled_texture, texture, alpha);
/* paint texture onto surface */
@@ -305,20 +315,20 @@ void Backdrop::Main::apply_fill(Xml_node operation)
}
-void Backdrop::Main::handle_config(unsigned)
+void Backdrop::Main::handle_config()
{
- config()->reload();
+ config.update();
- buffer.construct(nitpicker);
+ buffer.construct(env, nitpicker);
/* clear surface */
apply_fill(Xml_node(""));
/* apply graphics primitives defined in the config */
try {
- for (unsigned i = 0; i < config()->xml_node().num_sub_nodes(); i++) {
+ for (unsigned i = 0; i < config.xml().num_sub_nodes(); i++) {
try {
- Xml_node operation = config()->xml_node().sub_node(i);
+ Xml_node operation = config.xml().sub_node(i);
if (operation.has_type("image"))
apply_image(operation);
@@ -336,11 +346,11 @@ void Backdrop::Main::handle_config(unsigned)
} catch (...) { /* ignore failure to obtain config */ }
/* schedule buffer refresh */
- nitpicker.framebuffer()->sync_sigh(sync_dispatcher);
+ nitpicker.framebuffer()->sync_sigh(sync_handler);
}
-void Backdrop::Main::handle_sync(unsigned)
+void Backdrop::Main::handle_sync()
{
buffer->flush_surface();
_update_view();
@@ -356,21 +366,6 @@ void Backdrop::Main::handle_sync(unsigned)
extern "C" void _sigprocmask() { }
-int main(int argc, char **argv)
-{
- static Signal_receiver sig_rec;
+void Libc::Component::construct(Genode::Env &env) {
+ static Backdrop::Main application(env); }
- static Backdrop::Main application(sig_rec);
-
- /* process incoming signals */
- for (;;) {
- using namespace Genode;
-
- Signal sig = sig_rec.wait_for_signal();
- Signal_dispatcher_base *dispatcher =
- dynamic_cast(sig.context());
-
- if (dispatcher)
- dispatcher->dispatch(sig.num());
- }
-}
diff --git a/repos/gems/src/app/backdrop/target.mk b/repos/gems/src/app/backdrop/target.mk
index dbeb9f828d..810c7ef817 100644
--- a/repos/gems/src/app/backdrop/target.mk
+++ b/repos/gems/src/app/backdrop/target.mk
@@ -1,3 +1,3 @@
TARGET = backdrop
SRC_CC = main.cc
-LIBS = base config posix libpng zlib blit file
+LIBS = base libc libpng zlib blit file