mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* \brief Utility for the buffered pixel output via nitpicker
|
||||
* \brief Utility for the buffered pixel output via the GUI server interface
|
||||
* \author Norman Feske
|
||||
* \date 2014-08-22
|
||||
*/
|
||||
@@ -11,8 +11,8 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__GEMS__NITPICKER_BUFFER_H_
|
||||
#define _INCLUDE__GEMS__NITPICKER_BUFFER_H_
|
||||
#ifndef _INCLUDE__GEMS__GUI_BUFFER_H_
|
||||
#define _INCLUDE__GEMS__GUI_BUFFER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/ram_allocator.h>
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <gems/dither_painter.h>
|
||||
|
||||
|
||||
struct Nitpicker_buffer
|
||||
struct Gui_buffer
|
||||
{
|
||||
typedef Genode::Pixel_rgb888 Pixel_rgb888;
|
||||
typedef Genode::Pixel_rgb565 Pixel_rgb565;
|
||||
@@ -46,27 +46,27 @@ struct Nitpicker_buffer
|
||||
Genode::Ram_allocator &ram;
|
||||
Genode::Region_map &rm;
|
||||
|
||||
Nitpicker::Connection &nitpicker;
|
||||
Gui::Connection &gui;
|
||||
|
||||
Framebuffer::Mode const mode;
|
||||
|
||||
/**
|
||||
* Return dataspace capability for virtual framebuffer
|
||||
*/
|
||||
Genode::Dataspace_capability _ds_cap(Nitpicker::Connection &nitpicker)
|
||||
Genode::Dataspace_capability _ds_cap(Gui::Connection &gui)
|
||||
{
|
||||
/* setup virtual framebuffer mode */
|
||||
nitpicker.buffer(mode, true);
|
||||
gui.buffer(mode, true);
|
||||
|
||||
if (mode.format() != Framebuffer::Mode::RGB565) {
|
||||
Genode::warning("color mode ", mode, " not supported");
|
||||
return Genode::Dataspace_capability();
|
||||
}
|
||||
|
||||
return nitpicker.framebuffer()->dataspace();
|
||||
return gui.framebuffer()->dataspace();
|
||||
}
|
||||
|
||||
Genode::Attached_dataspace fb_ds { rm, _ds_cap(nitpicker) };
|
||||
Genode::Attached_dataspace fb_ds { rm, _ds_cap(gui) };
|
||||
|
||||
Genode::size_t pixel_surface_num_bytes() const
|
||||
{
|
||||
@@ -84,12 +84,12 @@ struct Nitpicker_buffer
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Nitpicker_buffer(Nitpicker::Connection &nitpicker, Area size,
|
||||
Genode::Ram_allocator &ram, Genode::Region_map &rm)
|
||||
Gui_buffer(Gui::Connection &gui, Area size,
|
||||
Genode::Ram_allocator &ram, Genode::Region_map &rm)
|
||||
:
|
||||
ram(ram), rm(rm), nitpicker(nitpicker),
|
||||
ram(ram), rm(rm), gui(gui),
|
||||
mode(Genode::max(1UL, size.w()), Genode::max(1UL, size.h()),
|
||||
nitpicker.mode().format())
|
||||
gui.mode().format())
|
||||
{
|
||||
reset_surface();
|
||||
}
|
||||
@@ -186,4 +186,4 @@ struct Nitpicker_buffer
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__GEMS__NITPICKER_BUFFER_H_ */
|
||||
#endif /* _INCLUDE__GEMS__GUI_BUFFER_H_ */
|
||||
@@ -3,7 +3,7 @@
|
||||
* \author Norman Feske
|
||||
* \date 2015-06-22
|
||||
*
|
||||
* The 'Scene' class template contains the code for setting up a nitpicker
|
||||
* The 'Scene' class template contains the code for setting up a GUI
|
||||
* view with a triple-buffer for rendering tearing-free animations.
|
||||
* A derrived class implements the to-be-displayed content in the virtual
|
||||
* 'render' method.
|
||||
@@ -64,12 +64,12 @@ class Nano3d::Scene
|
||||
Genode::Env &_env;
|
||||
|
||||
/**
|
||||
* Position and size of nitpicker view
|
||||
* Position and size of GUI view
|
||||
*/
|
||||
Nitpicker::Point const _pos;
|
||||
Nitpicker::Area const _size;
|
||||
Gui::Point const _pos;
|
||||
Gui::Area const _size;
|
||||
|
||||
Nitpicker::Connection _nitpicker { _env };
|
||||
Gui::Connection _gui { _env };
|
||||
|
||||
struct Mapped_framebuffer
|
||||
{
|
||||
@@ -78,10 +78,10 @@ class Nano3d::Scene
|
||||
Genode::Region_map &rm;
|
||||
|
||||
static Framebuffer::Session &
|
||||
_init_framebuffer(Nitpicker::Connection &nitpicker,
|
||||
Nitpicker::Area const size)
|
||||
_init_framebuffer(Gui::Connection &gui,
|
||||
Gui::Area const size)
|
||||
{
|
||||
Framebuffer::Mode::Format const format = nitpicker.mode().format();
|
||||
Framebuffer::Mode::Format const format = gui.mode().format();
|
||||
if (format != Framebuffer::Mode::RGB565) {
|
||||
Genode::error("framebuffer mode ", (int)format, " is not supported");
|
||||
throw Unsupported_color_depth();
|
||||
@@ -94,10 +94,10 @@ class Nano3d::Scene
|
||||
*/
|
||||
bool const use_alpha = true;
|
||||
unsigned const height = size.h()*NUM_BUFFERS;
|
||||
nitpicker.buffer(Framebuffer::Mode(size.w(), height, format),
|
||||
gui.buffer(Framebuffer::Mode(size.w(), height, format),
|
||||
use_alpha);
|
||||
|
||||
return *nitpicker.framebuffer();
|
||||
return *gui.framebuffer();
|
||||
}
|
||||
|
||||
Framebuffer::Session &framebuffer;
|
||||
@@ -107,9 +107,9 @@ class Nano3d::Scene
|
||||
/**
|
||||
* Return visible size
|
||||
*/
|
||||
Nitpicker::Area size() const
|
||||
Gui::Area size() const
|
||||
{
|
||||
return Nitpicker::Area(mode.width(), mode.height()/NUM_BUFFERS);
|
||||
return Gui::Area(mode.width(), mode.height()/NUM_BUFFERS);
|
||||
}
|
||||
|
||||
Genode::Attached_dataspace ds { rm, framebuffer.dataspace() };
|
||||
@@ -142,15 +142,15 @@ class Nano3d::Scene
|
||||
NUM_BUFFERS*size().count());
|
||||
}
|
||||
|
||||
Mapped_framebuffer(Nitpicker::Connection &nitpicker, Nitpicker::Area size,
|
||||
Mapped_framebuffer(Gui::Connection &gui, Gui::Area size,
|
||||
Genode::Region_map &rm)
|
||||
:
|
||||
rm(rm), framebuffer(_init_framebuffer(nitpicker, size))
|
||||
rm(rm), framebuffer(_init_framebuffer(gui, size))
|
||||
{ }
|
||||
|
||||
} _framebuffer { _nitpicker, _size, _env.rm() };
|
||||
} _framebuffer { _gui, _size, _env.rm() };
|
||||
|
||||
Nitpicker::Session::View_handle _view_handle = _nitpicker.create_view();
|
||||
Gui::Session::View_handle _view_handle = _gui.create_view();
|
||||
|
||||
typedef Genode::Surface<PT> Pixel_surface;
|
||||
typedef Genode::Surface<Genode::Pixel_alpha8> Alpha_surface;
|
||||
@@ -198,7 +198,7 @@ class Nano3d::Scene
|
||||
|
||||
Timer::Connection _timer { _env };
|
||||
|
||||
Genode::Attached_dataspace _input_ds { _env.rm(), _nitpicker.input()->dataspace() };
|
||||
Genode::Attached_dataspace _input_ds { _env.rm(), _gui.input()->dataspace() };
|
||||
|
||||
Input_handler *_input_handler_callback = nullptr;
|
||||
|
||||
@@ -207,7 +207,7 @@ class Nano3d::Scene
|
||||
if (!_input_handler_callback)
|
||||
return;
|
||||
|
||||
while (int num = _nitpicker.input()->flush()) {
|
||||
while (int num = _gui.input()->flush()) {
|
||||
|
||||
auto const *ev_buf = _input_ds.local_addr<Input::Event>();
|
||||
|
||||
@@ -266,9 +266,9 @@ class Nano3d::Scene
|
||||
: (_surface_visible == &_surface_1) ? -h
|
||||
: -2*h;
|
||||
|
||||
Nitpicker::Point const offset(0, buf_y);
|
||||
_nitpicker.enqueue<Command::Offset>(_view_handle, offset);
|
||||
_nitpicker.execute();
|
||||
Gui::Point const offset(0, buf_y);
|
||||
_gui.enqueue<Command::Offset>(_view_handle, offset);
|
||||
_gui.execute();
|
||||
|
||||
_do_sync = false;
|
||||
}
|
||||
@@ -276,23 +276,23 @@ class Nano3d::Scene
|
||||
Genode::Signal_handler<Scene> _sync_handler {
|
||||
_env.ep(), *this, &Scene::_handle_sync };
|
||||
|
||||
typedef Nitpicker::Session::Command Command;
|
||||
typedef Gui::Session::Command Command;
|
||||
|
||||
public:
|
||||
|
||||
Scene(Genode::Env &env, Genode::uint64_t update_rate_ms,
|
||||
Nitpicker::Point pos, Nitpicker::Area size)
|
||||
Gui::Point pos, Gui::Area size)
|
||||
:
|
||||
_env(env), _pos(pos), _size(size)
|
||||
{
|
||||
typedef Nitpicker::Session::View_handle View_handle;
|
||||
typedef Gui::Session::View_handle View_handle;
|
||||
|
||||
Nitpicker::Rect rect(_pos, _size);
|
||||
_nitpicker.enqueue<Command::Geometry>(_view_handle, rect);
|
||||
_nitpicker.enqueue<Command::To_front>(_view_handle, View_handle());
|
||||
_nitpicker.execute();
|
||||
Gui::Rect rect(_pos, _size);
|
||||
_gui.enqueue<Command::Geometry>(_view_handle, rect);
|
||||
_gui.enqueue<Command::To_front>(_view_handle, View_handle());
|
||||
_gui.execute();
|
||||
|
||||
_nitpicker.input()->sigh(_input_handler);
|
||||
_gui.input()->sigh(_input_handler);
|
||||
|
||||
_timer.sigh(_periodic_handler);
|
||||
_timer.trigger_periodic(1000*update_rate_ms);
|
||||
|
||||
Reference in New Issue
Block a user