nitpicker: let 'Connection' track donated quota

This patch adds support for the consecutive re-dimensioning the virtual
framebuffer. When changing the buffer size, the session gets upgraded by
the missing portion of the quota instead of donating the whole size of
the new buffer each time.
This commit is contained in:
Christian Prochaska 2014-06-12 12:25:38 +02:00 committed by Norman Feske
parent b5b1dd03bd
commit 6b42f8b54e
1 changed files with 13 additions and 3 deletions

View File

@ -30,6 +30,7 @@ class Nitpicker::Connection : public Genode::Connection<Session>,
Framebuffer::Session_client _framebuffer;
Input::Session_client _input;
Genode::size_t _session_quota = 0;
/**
* Create session and return typed session capability
@ -75,10 +76,19 @@ class Nitpicker::Connection : public Genode::Connection<Session>,
char argbuf[ARGBUF_SIZE];
argbuf[0] = 0;
Genode::Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota",
ram_quota(mode, use_alpha));
Genode::size_t const needed = ram_quota(mode, use_alpha);
Genode::size_t const upgrade = needed > _session_quota
? needed - _session_quota
: 0;
if (upgrade > 0) {
Genode::Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota",
upgrade);
Genode::env()->parent()->upgrade(cap(), argbuf);
_session_quota += upgrade;
}
Genode::env()->parent()->upgrade(cap(), argbuf);
Session_client::buffer(mode, use_alpha);
}