framebuffer_session: use Rect as refresh argument

This patch replaces basic-type arguments x, y, w, h by the 'Rect' type,
and imports the Genode namespace into the Framebuffer namespace.

Issue #5350
This commit is contained in:
Norman Feske 2024-09-23 15:05:51 +02:00 committed by Christian Helmuth
parent e1b24d1ebd
commit 0e33830d1f
28 changed files with 70 additions and 63 deletions

View File

@ -79,8 +79,8 @@ class Scout::Graphics_backend_impl : public Graphics_backend
void _refresh_view(Rect rect) void _refresh_view(Rect rect)
{ {
int const y_offset = _flip_state ? _max_size.h : 0; int const y_offset = _flip_state ? _max_size.h : 0;
_gui.framebuffer.refresh(rect.x1(), rect.y1() + y_offset, _gui.framebuffer.refresh({ { rect.x1(), rect.y1() + y_offset },
rect.w(), rect.h()); rect.area });
} }
template <typename PT> template <typename PT>

View File

@ -262,9 +262,9 @@ class Framebuffer::Session_component : public Genode::Rpc_object<Session>
_timer.trigger_periodic(10*1000); _timer.trigger_periodic(10*1000);
} }
void refresh(int x, int y, int w, int h) override void refresh(Rect rect) override
{ {
_window_content.redraw_area(x, y, w, h); _window_content.redraw_area(rect.x1(), rect.y1(), rect.w(), rect.h());
} }
}; };

View File

@ -444,7 +444,7 @@ struct Nitlog::Main
void _handle_timer() void _handle_timer()
{ {
if (_log_window.draw()) if (_log_window.draw())
_gui.framebuffer.refresh(0, 0, _win_w, _win_h); _gui.framebuffer.refresh({ { 0, 0 }, { _win_w, _win_h } });
} }
Main(Env &env) : _env(env) Main(Env &env) : _env(env)

View File

@ -82,7 +82,7 @@ struct Decorator::Main : Window_factory_base
Dirty_rect dirty = _window_stack.draw(_canvas->canvas); Dirty_rect dirty = _window_stack.draw(_canvas->canvas);
dirty.flush([&] (Rect const &r) { dirty.flush([&] (Rect const &r) {
_gui.framebuffer.refresh(r.x1(), r.y1(), r.w(), r.h()); }); _gui.framebuffer.refresh(r); });
} }
Window_stack _window_stack = { *this }; Window_stack _window_stack = { *this };
@ -322,7 +322,7 @@ void Decorator::Main::_handle_gui_sync()
_gui.execute(); _gui.execute();
dirty.flush([&] (Rect const &r) { dirty.flush([&] (Rect const &r) {
_gui.framebuffer.refresh(r.x1(), r.y1(), r.w(), r.h()); }); _gui.framebuffer.refresh(r); });
} }
/* /*

View File

@ -191,7 +191,7 @@ struct Menu_view::Dialog : List_model<Dialog>::Element
}); });
_buffer->flush_surface(); _buffer->flush_surface();
_gui.framebuffer.refresh(0, 0, _buffer->size().w, _buffer->size().h); _gui.framebuffer.refresh({ { 0, 0 }, _buffer->size() });
_update_view(Rect(_position, size)); _update_view(Rect(_position, size));
_redraw_scheduled = false; _redraw_scheduled = false;

View File

@ -159,7 +159,7 @@ struct Osci::Main
_gui_buffer->flush_surface(); _gui_buffer->flush_surface();
_gui.framebuffer.refresh(0, 0, _size.w, _size.h); _gui.framebuffer.refresh({ { 0, 0 }, _size });
} }
Main(Env &env) : _env(env) Main(Env &env) : _env(env)

View File

@ -305,7 +305,7 @@ struct Osci::Main
channel.render(pixel, alpha, phase_lock); }); }); channel.render(pixel, alpha, phase_lock); }); });
_gui_buffer->flush_surface(); _gui_buffer->flush_surface();
_gui.framebuffer.refresh(0, 0, _size.w, _size.h); _gui.framebuffer.refresh({ { 0, 0 }, _size });
} }
Main(Env &env) : _env(env) Main(Env &env) : _env(env)

View File

@ -287,7 +287,7 @@ class Decorator::Window : public Window_base, public Animator::Item
buffer.flush_surface(); buffer.flush_surface();
buffer.gui.framebuffer.refresh(0, 0, buffer.size().w, buffer.size().h); buffer.gui.framebuffer.refresh({ { 0, 0 }, buffer.size() });
} }
void _repaint_decorations() void _repaint_decorations()

View File

@ -207,7 +207,7 @@ class Gui_fader::Framebuffer_session_component
transfer_src_to_dst_alpha(rect); transfer_src_to_dst_alpha(rect);
_gui.framebuffer.refresh(rect.x1(), rect.y1(), rect.w(), rect.h()); _gui.framebuffer.refresh(rect);
/* keep animating as long as the destination value is not reached */ /* keep animating as long as the destination value is not reached */
return _fade != _fade.dst(); return _fade != _fade.dst();
@ -238,12 +238,12 @@ class Gui_fader::Framebuffer_session_component
_gui.framebuffer.mode_sigh(sigh); _gui.framebuffer.mode_sigh(sigh);
} }
void refresh(int x, int y, int w, int h) override void refresh(Rect rect) override
{ {
transfer_src_to_dst_pixel(Rect(Point(x, y), Area(w, h))); transfer_src_to_dst_pixel(rect);
transfer_src_to_dst_alpha(Rect(Point(x, y), Area(w, h))); transfer_src_to_dst_alpha(rect);
_gui.framebuffer.refresh(x, y, w, h); _gui.framebuffer.refresh(rect);
} }
void sync_sigh(Genode::Signal_context_capability sigh) override void sync_sigh(Genode::Signal_context_capability sigh) override

View File

@ -155,7 +155,7 @@ struct Terminal::Main : Character_consumer
Rect const dirty = _text_screen_surface->redraw(surface); Rect const dirty = _text_screen_surface->redraw(surface);
_gui.framebuffer.refresh(dirty.x1(), dirty.y1(), dirty.w(), dirty.h()); _gui.framebuffer.refresh(dirty);
} }
/* update view geometry after mode change */ /* update view geometry after mode change */

View File

@ -80,7 +80,7 @@ struct Test::Main
Vfs_font _font_4 { _heap, _root, "fonts/regular" }; Vfs_font _font_4 { _heap, _root, "fonts/regular" };
void _refresh() { _fb.refresh(0, 0, _size.w, _size.h); } void _refresh() { _fb.refresh({ { 0, 0 }, _size }); }
Main(Env &env) : _env(env) Main(Env &env) : _env(env)
{ {

View File

@ -306,7 +306,7 @@ void Pdf_view::show()
dst_line += dst_line_width; dst_line += dst_line_width;
} }
_gui.framebuffer.refresh(0, 0, _nit_mode.area.w, _nit_mode.area.h); _gui.framebuffer.refresh({ { 0, 0 }, _nit_mode.area });
} }

View File

@ -69,9 +69,7 @@ class Viewer
uint8_t *framebuffer() { return _framebuffer; } uint8_t *framebuffer() { return _framebuffer; }
void refresh() { void refresh() { _gui.framebuffer.refresh({ { 0, 0 }, _mode.area }); }
_gui.framebuffer.refresh(0, 0, _mode.area.w, _mode.area.h);
}
Framebuffer::Mode const &mode() { return _mode; } Framebuffer::Mode const &mode() { return _mode; }
}; };

View File

@ -82,7 +82,7 @@ struct Window : Genode_egl_window
void refresh() void refresh()
{ {
gui.framebuffer.refresh(0, 0, mode.area.w, mode.area.h); gui.framebuffer.refresh({ { 0, 0 }, mode.area });
} }
}; };

View File

@ -20,24 +20,35 @@
namespace Framebuffer { struct Session_client; } namespace Framebuffer { struct Session_client; }
struct Framebuffer::Session_client : Genode::Rpc_client<Session> struct Framebuffer::Session_client : Rpc_client<Session>
{ {
explicit Session_client(Session_capability session) explicit Session_client(Session_capability session)
: Genode::Rpc_client<Session>(session) { } : Rpc_client<Session>(session) { }
Genode::Dataspace_capability dataspace() override { Dataspace_capability dataspace() override {
return call<Rpc_dataspace>(); } return call<Rpc_dataspace>(); }
Mode mode() const override { return call<Rpc_mode>(); } Mode mode() const override { return call<Rpc_mode>(); }
void mode_sigh(Genode::Signal_context_capability sigh) override { void mode_sigh(Signal_context_capability sigh) override {
call<Rpc_mode_sigh>(sigh); } call<Rpc_mode_sigh>(sigh); }
void sync_sigh(Genode::Signal_context_capability sigh) override { void sync_sigh(Signal_context_capability sigh) override {
call<Rpc_sync_sigh>(sigh); } call<Rpc_sync_sigh>(sigh); }
void refresh(int x, int y, int w, int h) override { void refresh(Rect rect) override { call<Rpc_refresh>(rect); }
call<Rpc_refresh>(x, y, w, h); }
/**
* Flush specified pixel region
*
* \deprecated
* \noapi
*/
void refresh(int x, int y, int w, int h)
{
refresh(Rect { { x, y }, { unsigned(w), unsigned(h) } });
}
}; };
#endif /* _INCLUDE__FRAMEBUFFER_SESSION__CLIENT_H_ */ #endif /* _INCLUDE__FRAMEBUFFER_SESSION__CLIENT_H_ */

View File

@ -31,7 +31,7 @@ struct Framebuffer::Connection : Genode::Connection<Session>, Session_client
* session, you should validate the actual frame-buffer attributes * session, you should validate the actual frame-buffer attributes
* by calling the 'info' method of the frame-buffer interface. * by calling the 'info' method of the frame-buffer interface.
*/ */
Connection(Genode::Env &env, Framebuffer::Mode mode) Connection(Env &env, Framebuffer::Mode mode)
: :
Genode::Connection<Session>(env, Label(), Ram_quota { 8*1024 }, Genode::Connection<Session>(env, Label(), Ram_quota { 8*1024 },
Args("fb_width=", mode.area.w, ", " Args("fb_width=", mode.area.w, ", "

View File

@ -26,7 +26,11 @@ namespace Framebuffer {
struct Session; struct Session;
struct Session_client; struct Session_client;
using Area = Genode::Surface_base::Area; using namespace Genode;
using Area = Surface_base::Area;
using Point = Surface_base::Point;
using Rect = Surface_base::Rect;
} }
@ -37,9 +41,9 @@ struct Framebuffer::Mode
{ {
Area area; Area area;
Genode::size_t bytes_per_pixel() const { return 4; } size_t bytes_per_pixel() const { return 4; }
void print(Genode::Output &out) const { Genode::print(out, area); } void print(Output &out) const { Genode::print(out, area); }
}; };
@ -70,7 +74,7 @@ struct Framebuffer::Session : Genode::Session
* have detached the previously requested dataspace from its local * have detached the previously requested dataspace from its local
* address space. * address space.
*/ */
virtual Genode::Dataspace_capability dataspace() = 0; virtual Dataspace_capability dataspace() = 0;
/** /**
* Request display-mode properties of the framebuffer ready to be * Request display-mode properties of the framebuffer ready to be
@ -89,30 +93,30 @@ struct Framebuffer::Session : Genode::Session
* method. However, from the client's perspective, the original mode * method. However, from the client's perspective, the original mode
* stays in effect until the it calls 'dataspace()' again. * stays in effect until the it calls 'dataspace()' again.
*/ */
virtual void mode_sigh(Genode::Signal_context_capability sigh) = 0; virtual void mode_sigh(Signal_context_capability sigh) = 0;
/** /**
* Flush specified pixel region * Flush specified pixel region
* *
* \param x,y,w,h region to be updated on physical frame buffer * \param rect region to be updated on physical frame buffer
*/ */
virtual void refresh(int x, int y, int w, int h) = 0; virtual void refresh(Rect rect) = 0;
/** /**
* Register signal handler for refresh synchronization * Register signal handler for refresh synchronization
*/ */
virtual void sync_sigh(Genode::Signal_context_capability) = 0; virtual void sync_sigh(Signal_context_capability) = 0;
/********************* /*********************
** RPC declaration ** ** RPC declaration **
*********************/ *********************/
GENODE_RPC(Rpc_dataspace, Genode::Dataspace_capability, dataspace); GENODE_RPC(Rpc_dataspace, Dataspace_capability, dataspace);
GENODE_RPC(Rpc_mode, Mode, mode); GENODE_RPC(Rpc_mode, Mode, mode);
GENODE_RPC(Rpc_refresh, void, refresh, int, int, int, int); GENODE_RPC(Rpc_refresh, void, refresh, Rect);
GENODE_RPC(Rpc_mode_sigh, void, mode_sigh, Genode::Signal_context_capability); GENODE_RPC(Rpc_mode_sigh, void, mode_sigh, Signal_context_capability);
GENODE_RPC(Rpc_sync_sigh, void, sync_sigh, Genode::Signal_context_capability); GENODE_RPC(Rpc_sync_sigh, void, sync_sigh, Signal_context_capability);
GENODE_RPC_INTERFACE(Rpc_dataspace, Rpc_mode, Rpc_mode_sigh, Rpc_refresh, GENODE_RPC_INTERFACE(Rpc_dataspace, Rpc_mode, Rpc_mode_sigh, Rpc_refresh,
Rpc_sync_sigh); Rpc_sync_sigh);

View File

@ -163,7 +163,7 @@ void Pointer::Main::_show_default_pointer()
convert_default_pointer_data_to_pixels(ds.local_addr<Genode::Pixel_rgb888>(), convert_default_pointer_data_to_pixels(ds.local_addr<Genode::Pixel_rgb888>(),
pointer_size); pointer_size);
_gui.framebuffer.refresh(0, 0, pointer_size.w, pointer_size.h); _gui.framebuffer.refresh({ { 0, 0 }, pointer_size });
Gui::Rect geometry(Gui::Point(0, 0), pointer_size); Gui::Rect geometry(Gui::Point(0, 0), pointer_size);
_gui.enqueue<Gui::Session::Command::Geometry>(_view.id(), geometry); _gui.enqueue<Gui::Session::Command::Geometry>(_view.id(), geometry);
@ -224,7 +224,7 @@ void Pointer::Main::_show_shape_pointer(Shape_report &shape_report)
Dither_painter::paint(alpha_surface, texture); Dither_painter::paint(alpha_surface, texture);
} }
_gui.framebuffer.refresh(0, 0, shape_size.w, shape_size.h); _gui.framebuffer.refresh({ { 0, 0 }, shape_size });
Gui::Rect geometry(shape_hot, shape_size); Gui::Rect geometry(shape_hot, shape_size);
_gui.enqueue<Gui::Session::Command::Geometry>(_view.id(), geometry); _gui.enqueue<Gui::Session::Command::Geometry>(_view.id(), geometry);

View File

@ -157,7 +157,7 @@ void Status_bar::Buffer::draw(Domain_name const &domain_name,
_draw_label(surface, view_rect.center(_label_size(domain_name, label)), _draw_label(surface, view_rect.center(_label_size(domain_name, label)),
domain_name, label, color); domain_name, label, color);
_gui.framebuffer.refresh(0, 0, area.w, area.h); _gui.framebuffer.refresh({ { 0, 0 }, area });
} }

View File

@ -201,14 +201,14 @@ struct Framebuffer::Session_component : Genode::Rpc_object<Framebuffer::Session>
_mode_sigh = sigh; _mode_sigh = sigh;
} }
void refresh(int x, int y, int w, int h) override void refresh(Rect rect) override
{ {
if (_dataspace_is_new) { if (_dataspace_is_new) {
_view_updater.update_view(); _view_updater.update_view();
_dataspace_is_new = false; _dataspace_is_new = false;
} }
_gui.framebuffer.refresh(x, y, w, h); _gui.framebuffer.refresh(rect);
} }
void sync_sigh(Signal_context_capability sigh) override void sync_sigh(Signal_context_capability sigh) override

View File

@ -115,7 +115,7 @@ class Framebuffer::Session_component : public Rpc_object<Session>
_sync_sigh = sigh; _sync_sigh = sigh;
} }
void refresh(int x, int y, int w, int h) override; void refresh(Rect) override;
}; };
#endif /* _FRAMEBUFFER_SESSION_COMPONENT_H_ */ #endif /* _FRAMEBUFFER_SESSION_COMPONENT_H_ */

View File

@ -54,10 +54,8 @@ extern char _binary_default_tff_start[];
** Framebuffer::Session_component ** ** Framebuffer::Session_component **
************************************/ ************************************/
void Framebuffer::Session_component::refresh(int x, int y, int w, int h) void Framebuffer::Session_component::refresh(Rect rect)
{ {
Rect const rect(Point(x, y), Area(w, h));
_view_stack.mark_session_views_as_dirty(_session, rect); _view_stack.mark_session_views_as_dirty(_session, rect);
} }
@ -426,7 +424,7 @@ struct Nitpicker::Main : Focus_updater, Hover_updater,
/* flush pixels to the framebuffer, reset dirty_rect */ /* flush pixels to the framebuffer, reset dirty_rect */
_dirty_rect.flush([&] (Rect const &rect) { _dirty_rect.flush([&] (Rect const &rect) {
_fb.refresh(rect.x1(), rect.y1(), rect.w(), rect.h()); }); _fb.refresh(rect); });
/* deliver framebuffer synchronization events */ /* deliver framebuffer synchronization events */
for (Gui_session *s = _main._session_list.first(); s; s = s->next()) for (Gui_session *s = _main._session_list.first(); s; s = s->next())

View File

@ -223,7 +223,7 @@ void Vmm::Virtio_gpu_control_request::_resource_flush()
uint32_t line_dst = _device._fb_mode.area.w * BYTES_PER_PIXEL; uint32_t line_dst = _device._fb_mode.area.w * BYTES_PER_PIXEL;
blit(src, line_src, dst, line_dst, w*BYTES_PER_PIXEL, h); blit(src, line_src, dst, line_dst, w*BYTES_PER_PIXEL, h);
_device._gui.framebuffer.refresh(x, y, w, h); _device._gui.framebuffer.refresh({ { int(x), int(y) }, { w, h } });
}); });
} }

View File

@ -164,9 +164,7 @@ struct Test::Main
}); });
affected.for_each_rect([&] (Gui::Rect const rect) { affected.for_each_rect([&] (Gui::Rect const rect) {
_output->_gui.framebuffer.refresh(rect.x1(), rect.y1(), _output->_gui.framebuffer.refresh(rect); });
rect.w(), rect.h());
});
}); });
}); });

View File

@ -265,7 +265,7 @@ Test::Main::Main(Genode::Env &env) : _env(env)
} }
} }
_gui.framebuffer.refresh(0, 0, size.w, size.h); _gui.framebuffer.refresh({ { 0, 0 }, size });
_view_stack.construct(View_stack::Input_mask_ptr { .size = size, _view_stack.construct(View_stack::Input_mask_ptr { .size = size,
.ptr = input_mask }); .ptr = input_mask });

View File

@ -179,9 +179,7 @@ struct Test::Main
}); });
affected.for_each_rect([&] (Gui::Rect const rect) { affected.for_each_rect([&] (Gui::Rect const rect) {
_output->_gui.framebuffer.refresh(rect.x1(), rect.y1(), _output->_gui.framebuffer.refresh(rect); });
rect.w(), rect.h());
});
}); });
}); });

View File

@ -67,7 +67,7 @@ class Genodefb :
size_t const max_h = Genode::min(_fb_mode.area.h, _virtual_fb_mode.area.h); size_t const max_h = Genode::min(_fb_mode.area.h, _virtual_fb_mode.area.h);
size_t const num_pixels = _fb_mode.area.w * max_h; size_t const num_pixels = _fb_mode.area.w * max_h;
memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel()); memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel());
_gui.framebuffer.refresh(0, 0, _virtual_fb_mode.area.w, _virtual_fb_mode.area.h); _gui.framebuffer.refresh({ { 0, 0 }, _virtual_fb_mode.area });
} }
void _adjust_buffer() void _adjust_buffer()

View File

@ -65,7 +65,7 @@ class Genodefb :
size_t const max_h = Genode::min(_fb_mode.area.h, _virtual_fb_mode.area.h); size_t const max_h = Genode::min(_fb_mode.area.h, _virtual_fb_mode.area.h);
size_t const num_pixels = _fb_mode.area.w * max_h; size_t const num_pixels = _fb_mode.area.w * max_h;
memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel()); memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel());
_gui.framebuffer.refresh(0, 0, _virtual_fb_mode.area.w, _virtual_fb_mode.area.h); _gui.framebuffer.refresh({ { 0, 0 }, _virtual_fb_mode.area });
} }
void _adjust_buffer() void _adjust_buffer()