decorator: API transition

Issue #1987
This commit is contained in:
Norman Feske 2017-01-11 18:47:20 +01:00
parent 99bfc3c0e2
commit 81862a41e1
3 changed files with 26 additions and 18 deletions

View File

@ -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 <typename PT> class Canvas;
@ -60,11 +62,14 @@ class Decorator::Canvas : public Decorator::Canvas_base
{
private:
Genode::Surface<PT> _surface;
Genode::Ram_session &_ram;
Genode::Region_map &_rm;
Genode::Surface<PT> _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<PT> const &texture =
static_cast<Genode::Texture<PT> const &>(texture_by_id(id));
static_cast<Genode::Texture<PT> const &>(texture_by_id(id, _ram, _rm));
unsigned const alpha = 255;

View File

@ -48,7 +48,8 @@ struct Decorator::Main : Window_factory_base
_nitpicker.framebuffer()->dataspace()) };
Canvas<Pixel_rgb565> _canvas = { _fb_ds.local_addr<Pixel_rgb565>(),
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;

View File

@ -20,6 +20,8 @@
/* local includes */
#include "canvas.h"
using namespace Genode;
template <typename PT>
class Icon_texture : public Chunky_texture<PT>
@ -31,12 +33,13 @@ class Icon_texture : public Chunky_texture<PT>
*/
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<PT>(ram, Genode::Surface_base::Area(WIDTH, HEIGHT))
Chunky_texture<PT>(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<PT>::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<Genode::Pixel_rgb565> 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<Pixel_rgb565> 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) {