mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
parent
7180851b2f
commit
703d68c7c1
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,31 +36,33 @@ struct Texture_from_png_file
|
||||
typedef Genode::Texture<Genode::Pixel_rgb888> Texture;
|
||||
|
||||
File png_file;
|
||||
Png_image png_image { png_file.data<void>() };
|
||||
Png_image png_image;
|
||||
Texture &texture { *png_image.texture<Genode::Pixel_rgb888>() };
|
||||
|
||||
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<void>())
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
static Genode::Texture<Genode::Pixel_rgb888> 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<Genode::Pixel_rgb888> 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<Pixel_rgb888> const &texture = texture_by_id(TEXTURE_ID_DEFAULT, _alloc);
|
||||
Genode::Texture<Pixel_rgb888> 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<Pixel_rgb888> const &texture = texture_by_id(TEXTURE_ID_DEFAULT, _alloc);
|
||||
Genode::Texture<Pixel_rgb888> 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<Pixel_rgb888> 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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<Nitpicker_buffer> _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<Nitpicker_buffer> _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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user