From 81862a41e1a504da1a5103cb8984dd19e8f7ac8e Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 11 Jan 2017 18:47:20 +0100 Subject: [PATCH] decorator: API transition Issue #1987 --- repos/gems/src/app/decorator/canvas.h | 13 ++++++---- repos/gems/src/app/decorator/main.cc | 7 +++--- repos/gems/src/app/decorator/texture_by_id.cc | 24 ++++++++++--------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/repos/gems/src/app/decorator/canvas.h b/repos/gems/src/app/decorator/canvas.h index abb7dee208..953afa5dfe 100644 --- a/repos/gems/src/app/decorator/canvas.h +++ b/repos/gems/src/app/decorator/canvas.h @@ -34,7 +34,9 @@ namespace Decorator { TEXTURE_ID_WINDOWED }; - Genode::Texture_base const &texture_by_id(Texture_id); + Genode::Texture_base const &texture_by_id(Texture_id, + Genode::Ram_session &, + Genode::Region_map &); class Canvas_base; template class Canvas; @@ -60,11 +62,14 @@ class Decorator::Canvas : public Decorator::Canvas_base { private: - Genode::Surface _surface; + Genode::Ram_session &_ram; + Genode::Region_map &_rm; + Genode::Surface _surface; public: - Canvas(PT *base, Area size) : _surface(base, size) { } + Canvas(PT *base, Area size, Genode::Ram_session &ram, Genode::Region_map &rm) + : _ram(ram), _rm(rm), _surface(base, size) { } Rect clip() const override { return _surface.clip(); } @@ -84,7 +89,7 @@ class Decorator::Canvas : public Decorator::Canvas_base void draw_texture(Point pos, Texture_id id) { Genode::Texture const &texture = - static_cast const &>(texture_by_id(id)); + static_cast const &>(texture_by_id(id, _ram, _rm)); unsigned const alpha = 255; diff --git a/repos/gems/src/app/decorator/main.cc b/repos/gems/src/app/decorator/main.cc index d2c2f88b23..1dab0ec3a0 100644 --- a/repos/gems/src/app/decorator/main.cc +++ b/repos/gems/src/app/decorator/main.cc @@ -48,7 +48,8 @@ struct Decorator::Main : Window_factory_base _nitpicker.framebuffer()->dataspace()) }; Canvas _canvas = { _fb_ds.local_addr(), - Area(_mode.width(), _mode.height()) }; + Area(_mode.width(), _mode.height()), + _env.ram(), _env.rm() }; Window_stack _window_stack = { *this }; @@ -74,11 +75,11 @@ struct Decorator::Main : Window_factory_base Window_base::Hover _hover; - Reporter _hover_reporter = { "hover" }; + Reporter _hover_reporter = { _env, "hover" }; bool _window_layout_update_needed = false; - Reporter _decorator_margins_reporter = { "decorator_margins" }; + Reporter _decorator_margins_reporter = { _env, "decorator_margins" }; Animator _animator; diff --git a/repos/gems/src/app/decorator/texture_by_id.cc b/repos/gems/src/app/decorator/texture_by_id.cc index 4ebedcb103..ef5942c70c 100644 --- a/repos/gems/src/app/decorator/texture_by_id.cc +++ b/repos/gems/src/app/decorator/texture_by_id.cc @@ -20,6 +20,8 @@ /* local includes */ #include "canvas.h" +using namespace Genode; + template class Icon_texture : public Chunky_texture @@ -31,12 +33,13 @@ class Icon_texture : public Chunky_texture */ enum { WIDTH = 14, HEIGHT = 14 }; - Icon_texture(Genode::Ram_session &ram, unsigned char rgba_data[]) + Icon_texture(Ram_session &ram, Region_map &rm, + unsigned char rgba_data[]) : - Chunky_texture(ram, Genode::Surface_base::Area(WIDTH, HEIGHT)) + Chunky_texture(ram, rm, Surface_base::Area(WIDTH, HEIGHT)) { unsigned char const *src = rgba_data; - Genode::size_t const src_line_bytes = WIDTH*4; + size_t const src_line_bytes = WIDTH*4; for (unsigned y = 0; y < HEIGHT; y++, src += src_line_bytes) Chunky_texture::rgba(src, WIDTH, y); @@ -56,15 +59,14 @@ extern unsigned char _binary_windowed_rgba_start[]; /** * Return texture for the specified texture ID */ -Genode::Texture_base const &Decorator::texture_by_id(Texture_id id) +Texture_base const & +Decorator::texture_by_id(Texture_id id, Ram_session &ram, Region_map &rm) { - Genode::Ram_session &ram = *Genode::env()->ram_session(); - - static Icon_texture const icons[4] { - { ram, _binary_closer_rgba_start }, - { ram, _binary_minimize_rgba_start }, - { ram, _binary_maximize_rgba_start }, - { ram, _binary_windowed_rgba_start } }; + static Icon_texture const icons[4] { + { ram, rm, _binary_closer_rgba_start }, + { ram, rm, _binary_minimize_rgba_start }, + { ram, rm, _binary_maximize_rgba_start }, + { ram, rm, _binary_windowed_rgba_start } }; switch (id) {