Loading...
Searching...
No Matches
goos
// vi:set ft=cpp: -*- Mode: C++ -*-
/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/sys/capability>
#include <l4/re/dataspace>
#include <l4/re/video/colors>
#include <l4/sys/cxx/ipc_iface>
namespace L4Re { namespace Video {
class L4_EXPORT Goos;
class L4_EXPORT View
{
private:
friend class Goos;
L4::Cap<Goos> _goos;
unsigned _view_idx;
View(l4_cap_idx_t goos, unsigned idx)
: _goos(goos), _view_idx(_goos.is_valid() ? idx : ~0U) {}
unsigned view_index() const noexcept
{ return _goos.is_valid() ? _view_idx : ~0U; }
public:
View() : _goos(L4::Cap<Goos>::Invalid), _view_idx(~0U) {}
enum Flags
{
F_none = 0x00,
F_set_buffer = 0x01,
F_set_buffer_offset = 0x02,
F_set_bytes_per_line = 0x04,
F_set_pixel = 0x08,
F_set_position = 0x10,
F_dyn_allocated = 0x20,
F_set_background = 0x40,
F_set_flags = 0x80,
F_fully_dynamic = F_set_buffer | F_set_buffer_offset | F_set_bytes_per_line
| F_set_pixel | F_set_position | F_dyn_allocated,
};
enum V_flags
{
F_above = 0x1000,
F_flags_mask = 0xff000,
};
struct Info
{
unsigned flags = 0;
unsigned view_index = 0;
unsigned long xpos = 0;
unsigned long ypos = 0;
unsigned long width = 0;
unsigned long height = 0;
unsigned long buffer_offset = 0;
unsigned long bytes_per_line = 0;
Pixel_info pixel_info;
unsigned buffer_index = 0;
bool has_static_buffer() const { return !(flags & F_set_buffer); }
bool has_static_buffer_offset() const { return !(flags & F_set_buffer_offset); }
bool has_set_buffer() const { return flags & F_set_buffer; }
bool has_set_buffer_offset() const { return flags & F_set_buffer_offset; }
bool has_set_bytes_per_line() const { return flags & F_set_bytes_per_line; }
bool has_set_pixel() const { return flags & F_set_pixel; }
bool has_set_position() const { return flags & F_set_position; }
template< typename OUT >
void dump(OUT &s) const
{
s.printf("View::Info:\n"
" flags: %x\n"
" size: %ldx%ld\n"
" pos: %ldx%ld\n"
" bytes_per_line: %ld\n"
" buffer_offset: %lx\n"
" ",
flags, width, height, xpos, ypos,
bytes_per_line, buffer_offset);
pixel_info.dump(s);
s.printf("\n");
}
};
int info(Info *info) const noexcept;
int set_info(Info const &info) const noexcept;
int set_viewport(int scr_x, int scr_y, int w, int h, unsigned long buf_offset) const noexcept;
int stack(View const &pivot, bool behind = true) const noexcept;
int push_top() const noexcept
{ return stack(View(), true); }
int push_bottom() const noexcept
{ return stack(View(), false); }
int refresh(int x, int y, int w, int h) const noexcept;
bool valid() const { return _goos.is_valid(); }
};
class L4_EXPORT Goos :
public L4::Kobject_t<Goos, L4::Kobject, L4RE_PROTO_GOOS>
{
public:
enum Flags
{
F_auto_refresh = 0x01,
F_pointer = 0x02,
F_dynamic_views = 0x04,
F_dynamic_buffers = 0x08,
};
struct Info
{
unsigned long width;
unsigned long height;
unsigned flags;
unsigned num_static_views;
unsigned num_static_buffers;
Pixel_info pixel_info;
bool auto_refresh() const { return flags & F_auto_refresh; }
bool has_pointer() const { return flags & F_pointer; }
bool has_dynamic_views() const { return flags & F_dynamic_views; }
bool has_dynamic_buffers() const { return flags & F_dynamic_buffers; }
Info()
: width(0), height(0), flags(0), num_static_views(0),
num_static_buffers(0) {}
};
L4_INLINE_RPC(long, info, (Info *info));
L4_RPC(long, get_static_buffer, (unsigned idx,
L4::Ipc::Out<L4::Cap<L4Re::Dataspace> > rbuf));
L4_RPC(long, create_buffer, (unsigned long size,
L4::Ipc::Out<L4::Cap<L4Re::Dataspace> > rbuf));
L4_INLINE_RPC(long, delete_buffer, (unsigned idx));
// Use a wrapper for this RPC as we enacapsulate the View
L4_INLINE_RPC_NF(long, create_view, ());
int create_view(View *view, l4_utcb_t *utcb = l4_utcb()) const noexcept
{
long r = create_view_t::call(c(), utcb);
if (r < 0)
return r;
*view = View(cap(), r);
return r;
}
// Use a wrapper as Views are encapsulated
L4_INLINE_RPC_NF(long, delete_view, (unsigned index));
int delete_view(View const &v, l4_utcb_t *utcb = l4_utcb()) const noexcept
{
return delete_view_t::call(c(), v._view_idx, utcb);
}
View view(unsigned index) const noexcept;
L4_INLINE_RPC(long, refresh, (int x, int y, int w, int h));
// those are used by the View
L4_INLINE_RPC(long, view_info, (unsigned index, View::Info *info));
L4_INLINE_RPC(long, set_view_info, (unsigned index, View::Info const &info));
L4_INLINE_RPC(long, view_stack, (unsigned index, unsigned pivit, bool behind));
L4_INLINE_RPC(long, view_refresh, (unsigned index, int x, int y, int w, int h));
typedef L4::Typeid::Rpcs<
info_t, get_static_buffer_t, create_buffer_t, create_view_t, delete_buffer_t,
delete_view_t, view_info_t, set_view_info_t, view_stack_t, view_refresh_t,
refresh_t
> Rpcs;
};
inline View
Goos::view(unsigned index) const noexcept
{ return View(cap(), index); }
inline int
View::info(Info *info) const noexcept
{ return _goos->view_info(_view_idx, info); }
inline int
View::set_info(Info const &info) const noexcept
{ return _goos->set_view_info(_view_idx, info); }
inline int
View::stack(View const &pivot, bool behind) const noexcept
{ return _goos->view_stack(_view_idx, pivot._view_idx, behind); }
inline int
View::refresh(int x, int y, int w, int h) const noexcept
{ return _goos->view_refresh(_view_idx, x, y, w, h); }
inline int
View::set_viewport(int scr_x, int scr_y, int w, int h,
unsigned long buf_offset) const noexcept
{
Info i;
i.flags = F_set_buffer_offset | F_set_position;
i.buffer_offset = buf_offset;
i.buffer_index = 0;
i.view_index = 0;
i.bytes_per_line = 0;
i.pixel_info = Pixel_info();
i.xpos = scr_x;
i.ypos = scr_y;
i.width = w;
i.height = h;
return set_info(i);
}
}}
capability
L4::Cap related definitions.
L4Re::Video::Goos
Class that abstracts framebuffers.
Definition goos:225
L4Re::Video::Goos::create_buffer
long create_buffer(unsigned long size, L4::Ipc::Out< L4::Cap< L4Re::Dataspace > > rbuf)
Create a buffer.
L4Re::Video::Goos::Flags
Flags
Flags for a Goos.
Definition goos:229
L4Re::Video::Goos::F_dynamic_buffers
@ F_dynamic_buffers
Supports dynamically allocated buffers.
Definition goos:233
L4Re::Video::Goos::F_pointer
@ F_pointer
We have a mouse pointer.
Definition goos:231
L4Re::Video::Goos::F_dynamic_views
@ F_dynamic_views
Supports dynamically allocated views.
Definition goos:232
L4Re::Video::Goos::F_auto_refresh
@ F_auto_refresh
The graphics display is automatically refreshed.
Definition goos:230
L4Re::Video::Goos::info
long info(Info *info)
Return the Goos information of the Goos.
L4Re::Video::Goos::refresh
long refresh(int x, int y, int w, int h)
Trigger refreshing of the given area on the virtual screen.
L4Re::Video::Goos::create_view
int create_view(View *view, l4_utcb_t *utcb=l4_utcb()) const noexcept
Create a view.
Definition goos:312
L4Re::Video::Goos::view
View view(unsigned index) const noexcept
Return a view.
Definition goos:363
L4Re::Video::Goos::delete_buffer
long delete_buffer(unsigned idx)
Delete a buffer.
L4Re::Video::Goos::delete_view
int delete_view(View const &v, l4_utcb_t *utcb=l4_utcb()) const noexcept
Delete a view.
Definition goos:332
L4Re::Video::Goos::get_static_buffer
long get_static_buffer(unsigned idx, L4::Ipc::Out< L4::Cap< L4Re::Dataspace > > rbuf)
Return a static buffer of a Goos.
L4Re::Video::Pixel_info
Pixel information.
Definition colors:95
L4Re::Video::View
View of a framebuffer.
Definition goos:40
L4Re::Video::View::set_info
int set_info(Info const &info) const noexcept
Set the information structure for this view.
Definition goos:371
L4Re::Video::View::V_flags
V_flags
Property flags of a view.
Definition goos:83
L4Re::Video::View::F_above
@ F_above
Flag the view as stay on top.
Definition goos:84
L4Re::Video::View::F_flags_mask
@ F_flags_mask
Mask containing all possible property flags.
Definition goos:85
L4Re::Video::View::push_bottom
int push_bottom() const noexcept
Push this view the back.
Definition goos:189
L4Re::Video::View::info
int info(Info *info) const noexcept
Return the view information of the view.
Definition goos:367
L4Re::Video::View::push_top
int push_top() const noexcept
Make this view the top-most view.
Definition goos:185
L4Re::Video::View::valid
bool valid() const
Return whether this view is valid.
Definition goos:205
L4Re::Video::View::Flags
Flags
Flags on a view.
Definition goos:60
L4Re::Video::View::F_dyn_allocated
@ F_dyn_allocated
View is dynamically allocated.
Definition goos:67
L4Re::Video::View::F_none
@ F_none
everything for this view is static (the VESA-FB case)
Definition goos:61
L4Re::Video::View::F_set_bytes_per_line
@ F_set_bytes_per_line
bytes per line can be set
Definition goos:64
L4Re::Video::View::F_set_position
@ F_set_position
position on screen can be set
Definition goos:66
L4Re::Video::View::F_set_buffer_offset
@ F_set_buffer_offset
buffer offset can be set
Definition goos:63
L4Re::Video::View::F_set_pixel
@ F_set_pixel
pixel type can be set
Definition goos:65
L4Re::Video::View::F_set_background
@ F_set_background
Set view as background for session.
Definition goos:68
L4Re::Video::View::F_set_flags
@ F_set_flags
Set view flags (.
Definition goos:69
L4Re::Video::View::F_set_buffer
@ F_set_buffer
buffer object for this view can be changed
Definition goos:62
L4Re::Video::View::F_fully_dynamic
@ F_fully_dynamic
Flags for a fully dynamic view.
Definition goos:72
L4Re::Video::View::set_viewport
int set_viewport(int scr_x, int scr_y, int w, int h, unsigned long buf_offset) const noexcept
Set the position of the view in the Goos.
Definition goos:383
L4Re::Video::View::refresh
int refresh(int x, int y, int w, int h) const noexcept
Refresh/Redraw the view.
Definition goos:379
L4Re::Video::View::stack
int stack(View const &pivot, bool behind=true) const noexcept
Move this view in the view stack.
Definition goos:375
L4::Cap_base::Invalid
@ Invalid
Invalid capability selector.
Definition capability.h:42
L4::Cap
C++ interface for capabilities.
Definition capability.h:224
L4::Kobject_t
Helper class to create an L4Re interface class that is derived from a single base class.
Definition __typeinfo.h:750
L4::Kobject_t< Goos, L4::Kobject, L4RE_PROTO_GOOS >::c
L4::Cap< Class > c() const noexcept
Definition __typeinfo.h:769
L4::Kobject::cap
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition kobject:69
dataspace
Dataspace interface.
l4_cap_idx_t
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:336
l4_utcb_t
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
L4_EXPORT
#define L4_EXPORT
Attribute to mark functions, variables, and data types as being exported from a library.
Definition compiler.h:214
ipc_iface
Interface Definition Language.
L4_INLINE_RPC
#define L4_INLINE_RPC(res, name, args, attr...)
Define an inline RPC call (type and callable).
Definition ipc_iface:482
L4_RPC
#define L4_RPC(res, name, args, attr...)
Define an RPC call (type and callable).
Definition ipc_iface:541
L4_INLINE_RPC_NF
#define L4_INLINE_RPC_NF(res, name, args...)
Define an inline RPC call type (the type only, no callable).
Definition ipc_iface:453
L4Re
L4Re C++ Interfaces.
Definition cmd_control:14
L4Re::Video::Goos::Info
Information structure of a Goos.
Definition goos:238
L4Re::Video::Goos::Info::auto_refresh
bool auto_refresh() const
Return whether this Goos does auto refreshing or the view refresh functions must be used to make chan...
Definition goos:248
L4Re::Video::Goos::Info::height
unsigned long height
Height.
Definition goos:240
L4Re::Video::Goos::Info::width
unsigned long width
Width.
Definition goos:239
L4Re::Video::Goos::Info::pixel_info
Pixel_info pixel_info
Pixel information.
Definition goos:244
L4Re::Video::Goos::Info::has_dynamic_buffers
bool has_dynamic_buffers() const
Return whether dynamic buffers are supported.
Definition goos:254
L4Re::Video::Goos::Info::has_pointer
bool has_pointer() const
Return whether a pointer is used by the provider of the Goos.
Definition goos:250
L4Re::Video::Goos::Info::has_dynamic_views
bool has_dynamic_views() const
Return whether dynamic view are supported.
Definition goos:252
L4Re::Video::Goos::Info::flags
unsigned flags
Flags, see Flags.
Definition goos:241
L4Re::Video::Goos::Info::num_static_buffers
unsigned num_static_buffers
Number of static buffers.
Definition goos:243
L4Re::Video::Goos::Info::num_static_views
unsigned num_static_views
Number of static view.
Definition goos:242
L4Re::Video::View::Info
Information structure of a view.
Definition goos:92
L4Re::Video::View::Info::pixel_info
Pixel_info pixel_info
Pixel information.
Definition goos:102
L4Re::Video::View::Info::height
unsigned long height
Height of the view in pixels.
Definition goos:99
L4Re::Video::View::Info::width
unsigned long width
Width of the view in pixels.
Definition goos:98
L4Re::Video::View::Info::has_set_buffer
bool has_set_buffer() const
Return whether a buffer is set.
Definition goos:111
L4Re::Video::View::Info::buffer_index
unsigned buffer_index
Number of the buffer used for this view.
Definition goos:103
L4Re::Video::View::Info::xpos
unsigned long xpos
X position in pixels of the view in the Goos.
Definition goos:96
L4Re::Video::View::Info::view_index
unsigned view_index
Index of the view.
Definition goos:94
L4Re::Video::View::Info::buffer_offset
unsigned long buffer_offset
Offset in the memory buffer in bytes.
Definition goos:100
L4Re::Video::View::Info::has_set_pixel
bool has_set_pixel() const
Return whether the given pixel information is valid.
Definition goos:117
L4Re::Video::View::Info::bytes_per_line
unsigned long bytes_per_line
Bytes per line.
Definition goos:101
L4Re::Video::View::Info::has_static_buffer
bool has_static_buffer() const
Return whether the view has a static buffer.
Definition goos:106
L4Re::Video::View::Info::dump
void dump(OUT &s) const
Dump information on the view information to a stream.
Definition goos:123
L4Re::Video::View::Info::has_set_buffer_offset
bool has_set_buffer_offset() const
Return whether the given buffer offset is valid.
Definition goos:113
L4Re::Video::View::Info::ypos
unsigned long ypos
Y position in pixels of the view in the Goos.
Definition goos:97
L4Re::Video::View::Info::has_set_bytes_per_line
bool has_set_bytes_per_line() const
Return whether the given bytes-per-line value is valid.
Definition goos:115
L4Re::Video::View::Info::flags
unsigned flags
Flags, see Flags and V_flags.
Definition goos:93
L4Re::Video::View::Info::has_static_buffer_offset
bool has_static_buffer_offset() const
Return whether the static buffer offset is available.
Definition goos:108
L4Re::Video::View::Info::has_set_position
bool has_set_position() const
Return whether the position information given is valid.
Definition goos:119
L4::Ipc::Out
Mark an argument as a output value in an RPC signature.
Definition ipc_types:31
L4::Typeid::Rpcs
Standard list of RPCs of an interface.
Definition __typeinfo.h:428