loader: fix the 'constrain_geometry()' function

Fixes #1014.
This commit is contained in:
Christian Prochaska 2014-01-07 18:39:25 +01:00 committed by Norman Feske
parent cbd3d0a878
commit efd20a7ded
3 changed files with 49 additions and 42 deletions

View File

@ -86,8 +86,6 @@ namespace Loader {
Init::Child_policy_enforce_labeling _labeling_policy;
Init::Child_policy_pd_args _pd_args_policy;
int _max_width, _max_height;
Genode::Child _child;
Rom_session_capability _rom_session(char const *name)
@ -115,9 +113,7 @@ namespace Loader {
Service &local_cpu_service,
Service &local_rm_service,
Service &local_nitpicker_service,
Signal_context_capability fault_sigh,
int max_width,
int max_height)
Signal_context_capability fault_sigh)
:
_label(label),
_pd_args(pd_args),
@ -132,7 +128,6 @@ namespace Loader {
_binary_policy("binary", _binary_rom_session.dataspace(), &_ep),
_labeling_policy(_label.string),
_pd_args_policy(&_pd_args),
_max_width(max_width), _max_height(max_height),
_child(_binary_rom_session.dataspace(),
_resources.ram.cap(), _resources.cpu.cap(),
_resources.rm.cap(), &_ep, this)
@ -155,29 +150,6 @@ namespace Loader {
{
_labeling_policy.filter_session_args(service, args, args_len);
_pd_args_policy. filter_session_args(service, args, args_len);
if (!strcmp(service, "Nitpicker")) {
/*
* Restrict the child's framebuffer size to the maximum
* size given by the client.
*/
if (_max_width > -1) {
int fb_width = Arg_string::find_arg(args, "fb_width" ).long_value(_max_width);
if (!Arg_string::set_arg(args, args_len, "fb_width",
min(fb_width, _max_width))) {
PERR("could not set fb_width argument");
}
}
if (_max_height > -1) {
int fb_height = Arg_string::find_arg(args, "fb_height" ).long_value(_max_height);
if (!Arg_string::set_arg(args, args_len, "fb_height",
min(fb_height, _max_height))) {
PERR("could not set fb_height argument");
}
}
}
}
Service *resolve_session_request(const char *name,

View File

@ -176,6 +176,9 @@ namespace Loader {
Rpc_entrypoint &ep;
Allocator &_md_alloc;
int _max_width;
int _max_height;
Signal_context_capability view_ready_sigh;
Nitpicker::Session_component *open_session;
@ -186,6 +189,8 @@ namespace Loader {
Service("virtual_nitpicker"),
ep(ep),
_md_alloc(md_alloc),
_max_width(-1),
_max_height(-1),
open_session(0)
{ }
@ -198,6 +203,11 @@ namespace Loader {
destroy(&_md_alloc, open_session);
}
void constrain_geometry(int width, int height)
{
_max_width = width, _max_height = height;
}
Genode::Session_capability session(char const *args,
Affinity const &)
{
@ -205,7 +215,11 @@ namespace Loader {
throw Unavailable();
open_session = new (&_md_alloc)
Nitpicker::Session_component(ep, view_ready_sigh, args);
Nitpicker::Session_component(ep,
_max_width,
_max_height,
view_ready_sigh,
args);
return ep.manage(open_session);
}
@ -219,7 +233,6 @@ namespace Loader {
Ram_session_client_guard _ram_session_client;
Heap _md_alloc;
size_t _subsystem_ram_quota_limit;
int _width, _height;
Rpc_entrypoint _ep;
Service_registry _parent_services;
Rom_module_registry _rom_modules;
@ -252,7 +265,6 @@ namespace Loader {
_ram_session_client(env()->ram_session_cap(), _ram_quota),
_md_alloc(&_ram_session_client, env()->rm_session()),
_subsystem_ram_quota_limit(0),
_width(-1), _height(-1),
_ep(&cap, STACK_SIZE, "session_ep"),
_rom_modules(_ram_session_client, _md_alloc),
_rom_service(_ep, _md_alloc, _rom_modules),
@ -300,7 +312,7 @@ namespace Loader {
void constrain_geometry(int width, int height)
{
_width = width, _height = height;
_nitpicker_service.constrain_geometry(width, height);
}
void view_ready_sigh(Signal_context_capability sigh)
@ -346,7 +358,7 @@ namespace Loader {
pd_args, _ep, _ram_session_client,
ram_quota, _parent_services, _rom_service,
_cpu_service, _rm_service, _nitpicker_service,
_fault_sigh, _width, _height);
_fault_sigh);
}
catch (Genode::Parent::Service_denied) {
throw Rom_module_does_not_exist(); }

View File

@ -161,6 +161,9 @@ namespace Nitpicker {
Rpc_entrypoint &_ep;
int _max_width;
int _max_height;
Nitpicker::Connection _nitpicker;
View_capability _nitpicker_view;
@ -181,12 +184,17 @@ namespace Nitpicker {
/**
* Constructor
*/
Session_component(Rpc_entrypoint &ep,
Signal_context_capability view_ready_sigh,
const char *args)
Session_component(Rpc_entrypoint &ep,
int max_width,
int max_height,
Signal_context_capability view_ready_sigh,
const char *args)
:
_ep(ep),
_max_width(max_width),
_max_height(max_height),
/* create Nitpicker view */
_nitpicker_view(_nitpicker.create_view()),
@ -235,7 +243,16 @@ namespace Nitpicker {
Framebuffer::Mode mode()
{
return _nitpicker.mode();
int mode_width = (_max_width > -1) ?
_max_width :
_nitpicker.mode().width();
int mode_height = (_max_height > -1) ?
_max_height :
_nitpicker.mode().height();
return Framebuffer::Mode(mode_width, mode_height,
_nitpicker.mode().format());
}
void buffer(Framebuffer::Mode mode, bool use_alpha)
@ -271,11 +288,17 @@ namespace Nitpicker {
*/
Loader::Session::View_geometry loader_view_geometry()
{
Framebuffer::Session_client framebuffer(framebuffer_session());
Framebuffer::Mode const mode = framebuffer.mode();
int view_width = (_max_width > -1) ?
min(_proxy_view.w(), _max_width) :
_proxy_view.w();
int view_height = (_max_height > -1) ?
min(_proxy_view.h(), _max_height) :
_proxy_view.h();
Loader::Session::View_geometry result(
min(_proxy_view.w(), mode.width()),
min(_proxy_view.h(), mode.height()),
view_width,
view_height,
_proxy_view.buf_x(),
_proxy_view.buf_y());