diff --git a/repos/gems/src/app/themed_decorator/main.cc b/repos/gems/src/app/themed_decorator/main.cc index 3c207d46e1..31dc419551 100644 --- a/repos/gems/src/app/themed_decorator/main.cc +++ b/repos/gems/src/app/themed_decorator/main.cc @@ -60,7 +60,7 @@ struct Decorator::Main : Window_factory_base Window_base::Hover _hover; - Reporter _hover_reporter = { "hover" }; + Reporter _hover_reporter = { _env, "hover" }; /** * Nitpicker connection used to sync animations @@ -73,9 +73,9 @@ struct Decorator::Main : Window_factory_base Heap _heap { _env.ram(), _env.rm() }; - Theme _theme { _heap }; + Theme _theme { _env.ram(), _env.rm(), _heap }; - Reporter _decorator_margins_reporter = { "decorator_margins" }; + Reporter _decorator_margins_reporter = { _env, "decorator_margins" }; /** * Process the update every 'frame_period' nitpicker sync signals. The @@ -166,8 +166,8 @@ struct Decorator::Main : Window_factory_base Window_base *create(Xml_node window_node) override { return new (_heap) - Window(attribute(window_node, "id", 0UL), _nitpicker, _animator, - _env.ram(), _theme, _decorator_config); + Window(_env, attribute(window_node, "id", 0UL), _nitpicker, _animator, + _theme, _decorator_config); } /** diff --git a/repos/gems/src/app/themed_decorator/theme.cc b/repos/gems/src/app/themed_decorator/theme.cc index b6a171fa14..3a54a9a965 100644 --- a/repos/gems/src/app/themed_decorator/theme.cc +++ b/repos/gems/src/app/themed_decorator/theme.cc @@ -36,31 +36,33 @@ struct Texture_from_png_file typedef Genode::Texture Texture; File png_file; - Png_image png_image { png_file.data() }; + Png_image png_image; Texture &texture { *png_image.texture() }; - Texture_from_png_file(char const *path, Genode::Allocator &alloc) + Texture_from_png_file(Genode::Ram_session &ram, Genode::Region_map &rm, + Genode::Allocator &alloc, char const *path) : - png_file(path, alloc) + png_file(path, alloc), png_image(ram, rm, alloc, png_file.data()) { } }; static Genode::Texture const & -texture_by_id(Texture_id texture_id, Genode::Allocator &alloc) +texture_by_id(Genode::Ram_session &ram, Genode::Region_map &rm, + Genode::Allocator &alloc, Texture_id texture_id) { if (texture_id == TEXTURE_ID_DEFAULT) { - static Texture_from_png_file texture("theme/default.png", alloc); + static Texture_from_png_file texture(ram, rm, alloc, "theme/default.png"); return texture.texture; } if (texture_id == TEXTURE_ID_CLOSER) { - static Texture_from_png_file texture("theme/closer.png", alloc); + static Texture_from_png_file texture(ram, rm, alloc, "theme/closer.png"); return texture.texture; } if (texture_id == TEXTURE_ID_MAXIMIZER) { - static Texture_from_png_file texture("theme/maximizer.png", alloc); + static Texture_from_png_file texture(ram, rm, alloc, "theme/maximizer.png"); return texture.texture; } @@ -70,14 +72,15 @@ texture_by_id(Texture_id texture_id, Genode::Allocator &alloc) static Genode::Texture const & -texture_by_element_type(Decorator::Theme::Element_type type, Genode::Allocator &alloc) +texture_by_element_type(Genode::Ram_session &ram, Genode::Region_map &rm, + Genode::Allocator &alloc, Decorator::Theme::Element_type type) { switch (type) { case Decorator::Theme::ELEMENT_TYPE_CLOSER: - return texture_by_id(TEXTURE_ID_CLOSER, alloc); + return texture_by_id(ram, rm, alloc, TEXTURE_ID_CLOSER); case Decorator::Theme::ELEMENT_TYPE_MAXIMIZER: - return texture_by_id(TEXTURE_ID_MAXIMIZER, alloc); + return texture_by_id(ram, rm, alloc, TEXTURE_ID_MAXIMIZER); } struct Invalid_element_type { }; throw Invalid_element_type(); @@ -106,7 +109,8 @@ Decorator::Area Decorator::Theme::background_size() const if (decor_margins().none() && aura_margins().none()) return Decorator::Area(0, 0); - Genode::Texture const &texture = texture_by_id(TEXTURE_ID_DEFAULT, _alloc); + Genode::Texture const &texture = + texture_by_id(_ram, _rm, _alloc, TEXTURE_ID_DEFAULT); return texture.size(); } @@ -150,7 +154,8 @@ Decorator::Rect Decorator::Theme::title_geometry() const static Decorator::Rect -element_geometry(Genode::Allocator &alloc, char const *sub_node_type, +element_geometry(Genode::Ram_session &ram, Genode::Region_map &rm, + Genode::Allocator &alloc, char const *sub_node_type, Texture_id texture_id) { using namespace Decorator; @@ -161,7 +166,7 @@ element_geometry(Genode::Allocator &alloc, char const *sub_node_type, return Rect(Point(0, 0), Area(0, 0)); return Rect(point_attribute(node.sub_node(sub_node_type)), - texture_by_id(texture_id, alloc).size()); + texture_by_id(ram, rm, alloc, texture_id).size()); } @@ -169,10 +174,10 @@ Decorator::Rect Decorator::Theme::element_geometry(Element_type type) const { if (type == ELEMENT_TYPE_CLOSER) - return ::element_geometry(_alloc, "closer", TEXTURE_ID_CLOSER); + return ::element_geometry(_ram, _rm, _alloc, "closer", TEXTURE_ID_CLOSER); if (type == ELEMENT_TYPE_MAXIMIZER) - return ::element_geometry(_alloc, "maximizer", TEXTURE_ID_MAXIMIZER); + return ::element_geometry(_ram, _rm, _alloc, "maximizer", TEXTURE_ID_MAXIMIZER); struct Invalid_element_type { }; throw Invalid_element_type(); @@ -191,7 +196,8 @@ void Decorator::Theme::draw_background(Decorator::Pixel_surface pixel_surface, if (!background_size().valid()) return; - Genode::Texture const &texture = texture_by_id(TEXTURE_ID_DEFAULT, _alloc); + Genode::Texture const &texture = + texture_by_id(_ram, _rm, _alloc, TEXTURE_ID_DEFAULT); typedef Genode::Surface_base::Point Point; typedef Genode::Surface_base::Rect Rect; @@ -280,7 +286,7 @@ void Decorator::Theme::draw_element(Decorator::Pixel_surface pixel_surface, return; Genode::Texture const &texture = - texture_by_element_type(element_type, _alloc); + texture_by_element_type(_ram, _rm, _alloc, element_type); Rect const surface_rect(Point(0, 0), pixel_surface.size()); Rect const element_rect = element_geometry(element_type); diff --git a/repos/gems/src/app/themed_decorator/theme.h b/repos/gems/src/app/themed_decorator/theme.h index 8ffbeb5ffa..73f495e3ee 100644 --- a/repos/gems/src/app/themed_decorator/theme.h +++ b/repos/gems/src/app/themed_decorator/theme.h @@ -41,7 +41,9 @@ class Decorator::Theme { private: - Genode::Allocator &_alloc; + Genode::Ram_session &_ram; + Genode::Region_map &_rm; + Genode::Allocator &_alloc; public: @@ -54,7 +56,8 @@ class Decorator::Theme enum Element_type { ELEMENT_TYPE_CLOSER, ELEMENT_TYPE_MAXIMIZER }; - Theme(Genode::Allocator &alloc) : _alloc(alloc) { } + Theme(Genode::Ram_session &ram, Genode::Region_map &rm, Genode::Allocator &alloc) + : _ram(ram), _rm(rm), _alloc(alloc) { } Area background_size() const; diff --git a/repos/gems/src/app/themed_decorator/window.h b/repos/gems/src/app/themed_decorator/window.h index 75de78f503..f6c3c6e895 100644 --- a/repos/gems/src/app/themed_decorator/window.h +++ b/repos/gems/src/app/themed_decorator/window.h @@ -45,7 +45,7 @@ class Decorator::Window : public Window_base, public Animator::Item { private: - Genode::Ram_session &_ram; + Genode::Env &_env; Theme const &_theme; @@ -231,14 +231,14 @@ class Decorator::Window : public Window_base, public Animator::Item * Nitpicker session that contains the upper and lower window * decorations. */ - Nitpicker::Connection _nitpicker_top_bottom; + Nitpicker::Connection _nitpicker_top_bottom { _env }; Genode::Constructible _buffer_top_bottom; /** * Nitpicker session that contains the left and right window * decorations. */ - Nitpicker::Connection _nitpicker_left_right; + Nitpicker::Connection _nitpicker_left_right { _env }; Genode::Constructible _buffer_left_right; Nitpicker_view _bottom_view { _nitpicker, _nitpicker_top_bottom }, @@ -264,7 +264,8 @@ class Decorator::Window : public Window_base, public Animator::Item Framebuffer::Mode::RGB565), use_alpha); - _buffer_top_bottom.construct(_nitpicker_top_bottom, size_top_bottom, _ram); + _buffer_top_bottom.construct(_nitpicker_top_bottom, size_top_bottom, + _env.ram(), _env.rm()); Area const size_left_right(outer_size.w() - inner_size.w(), outer_size.h()); @@ -274,7 +275,8 @@ class Decorator::Window : public Window_base, public Animator::Item Framebuffer::Mode::RGB565), use_alpha); - _buffer_left_right.construct(_nitpicker_left_right, size_left_right, _ram); + _buffer_left_right.construct(_nitpicker_left_right, size_left_right, + _env.ram(), _env.rm()); } void _repaint_decorations(Nitpicker_buffer &buffer) @@ -314,13 +316,12 @@ class Decorator::Window : public Window_base, public Animator::Item public: - Window(unsigned id, Nitpicker::Session_client &nitpicker, - Animator &animator, Genode::Ram_session &ram, - Theme const &theme, Config const &config) + Window(Genode::Env &env, unsigned id, Nitpicker::Session_client &nitpicker, + Animator &animator, Theme const &theme, Config const &config) : Window_base(id), Animator::Item(animator), - _ram(ram), _theme(theme), _animator(animator), + _env(env),_theme(theme), _animator(animator), _nitpicker(nitpicker), _config(config) { _reallocate_nitpicker_buffers();