L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
goos
1// vi:set ft=cpp: -*- Mode: C++ -*-
2/*
3 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
4 * Alexander Warg <warg@os.inf.tu-dresden.de>
5 * economic rights: Technische Universität Dresden (Germany)
6 *
7 * License: see LICENSE.spdx (in this directory or the directories above)
8 */
9#pragma once
10
11#include <l4/sys/capability>
12#include <l4/re/dataspace>
13#include <l4/re/video/colors>
14#include <l4/sys/cxx/ipc_iface>
15
16namespace L4Re { namespace Video {
17
26class L4_EXPORT Goos;
27
40{
41private:
42 friend class Goos;
43
44 L4::Cap<Goos> _goos;
45 unsigned _view_idx;
46
47 View(l4_cap_idx_t goos, unsigned idx)
48 : _goos(goos), _view_idx(_goos.is_valid() ? idx : ~0U) {}
49
50 unsigned view_index() const noexcept
51 { return _goos.is_valid() ? _view_idx : ~0U; }
52
53public:
54 View() : _goos(L4::Cap<Goos>::Invalid), _view_idx(~0U) {}
55
59 enum Flags
60 {
61 F_none = 0x00,
62 F_set_buffer = 0x01,
63 F_set_buffer_offset = 0x02,
64 F_set_bytes_per_line = 0x04,
65 F_set_pixel = 0x08,
66 F_set_position = 0x10,
67 F_dyn_allocated = 0x20,
68 F_set_background = 0x40,
69 F_set_flags = 0x80,
70
72 F_fully_dynamic = F_set_buffer | F_set_buffer_offset | F_set_bytes_per_line
73 | F_set_pixel | F_set_position | F_dyn_allocated,
74 };
75
83 {
84 F_above = 0x1000,
85 F_flags_mask = 0xff000,
86 };
87
91 struct Info
92 {
93 unsigned flags = 0;
94 unsigned view_index = 0;
95
96 unsigned long xpos = 0;
97 unsigned long ypos = 0;
98 unsigned long width = 0;
99 unsigned long height = 0;
100 unsigned long buffer_offset = 0;
101 unsigned long bytes_per_line = 0;
103 unsigned buffer_index = 0;
104
106 bool has_static_buffer() const { return !(flags & F_set_buffer); }
108 bool has_static_buffer_offset() const { return !(flags & F_set_buffer_offset); }
109
111 bool has_set_buffer() const { return flags & F_set_buffer; }
113 bool has_set_buffer_offset() const { return flags & F_set_buffer_offset; }
115 bool has_set_bytes_per_line() const { return flags & F_set_bytes_per_line; }
117 bool has_set_pixel() const { return flags & F_set_pixel; }
119 bool has_set_position() const { return flags & F_set_position; }
120
122 template< typename OUT >
123 void dump(OUT &s) const
124 {
125 s.printf("View::Info:\n"
126 " flags: %x\n"
127 " size: %ldx%ld\n"
128 " pos: %ldx%ld\n"
129 " bytes_per_line: %ld\n"
130 " buffer_offset: %lx\n"
131 " ",
132 flags, width, height, xpos, ypos,
133 bytes_per_line, buffer_offset);
134 pixel_info.dump(s);
135 s.printf("\n");
136 }
137 };
138
146 int info(Info *info) const noexcept;
147
158 int set_info(Info const &info) const noexcept;
159
171 int set_viewport(int scr_x, int scr_y, int w, int h, unsigned long buf_offset) const noexcept;
172
182 int stack(View const &pivot, bool behind = true) const noexcept;
183
185 int push_top() const noexcept
186 { return stack(View(), true); }
187
189 int push_bottom() const noexcept
190 { return stack(View(), false); }
191
202 int refresh(int x, int y, int w, int h) const noexcept;
203
205 bool valid() const { return _goos.is_valid(); }
206};
207
208
224 public L4::Kobject_t<Goos, L4::Kobject, L4RE_PROTO_GOOS>
225{
226public:
228 enum Flags
229 {
230 F_auto_refresh = 0x01,
231 F_pointer = 0x02,
232 F_dynamic_views = 0x04,
233 F_dynamic_buffers = 0x08,
234 };
235
237 struct Info
238 {
239 unsigned long width;
240 unsigned long height;
241 unsigned flags;
245
248 bool auto_refresh() const { return flags & F_auto_refresh; }
250 bool has_pointer() const { return flags & F_pointer; }
252 bool has_dynamic_views() const { return flags & F_dynamic_views; }
254 bool has_dynamic_buffers() const { return flags & F_dynamic_buffers; }
255
256 Info()
257 : width(0), height(0), flags(0), num_static_views(0),
258 num_static_buffers(0) {}
259 };
260
268 L4_INLINE_RPC(long, info, (Info *info));
269
278 L4_RPC(long, get_static_buffer, (unsigned idx,
280
289 L4_RPC(long, create_buffer, (unsigned long size,
291
299 L4_INLINE_RPC(long, delete_buffer, (unsigned idx));
300
301 // Use a wrapper for this RPC as we enacapsulate the View
302 L4_INLINE_RPC_NF(long, create_view, ());
303
312 int create_view(View *view, l4_utcb_t *utcb = l4_utcb()) const noexcept
313 {
314 long r = create_view_t::call(c(), utcb);
315 if (r < 0)
316 return r;
317 *view = View(cap(), r);
318 return r;
319 }
320
321 // Use a wrapper as Views are encapsulated
322 L4_INLINE_RPC_NF(long, delete_view, (unsigned index));
323
332 int delete_view(View const &v, l4_utcb_t *utcb = l4_utcb()) const noexcept
333 {
334 return delete_view_t::call(c(), v._view_idx, utcb);
335 }
336
342 View view(unsigned index) const noexcept;
343
347 L4_INLINE_RPC(long, refresh, (int x, int y, int w, int h));
348
349 // those are used by the View
350 L4_INLINE_RPC(long, view_info, (unsigned index, View::Info *info));
351 L4_INLINE_RPC(long, set_view_info, (unsigned index, View::Info const &info));
352 L4_INLINE_RPC(long, view_stack, (unsigned index, unsigned pivit, bool behind));
353 L4_INLINE_RPC(long, view_refresh, (unsigned index, int x, int y, int w, int h));
354
355 typedef L4::Typeid::Rpcs<
356 info_t, get_static_buffer_t, create_buffer_t, create_view_t, delete_buffer_t,
357 delete_view_t, view_info_t, set_view_info_t, view_stack_t, view_refresh_t,
358 refresh_t
359 > Rpcs;
360};
361
362inline View
363Goos::view(unsigned index) const noexcept
364{ return View(cap(), index); }
365
366inline int
367View::info(Info *info) const noexcept
368{ return _goos->view_info(_view_idx, info); }
369
370inline int
371View::set_info(Info const &info) const noexcept
372{ return _goos->set_view_info(_view_idx, info); }
373
374inline int
375View::stack(View const &pivot, bool behind) const noexcept
376{ return _goos->view_stack(_view_idx, pivot._view_idx, behind); }
377
378inline int
379View::refresh(int x, int y, int w, int h) const noexcept
380{ return _goos->view_refresh(_view_idx, x, y, w, h); }
381
382inline int
383View::set_viewport(int scr_x, int scr_y, int w, int h,
384 unsigned long buf_offset) const noexcept
385{
386 Info i;
387 i.flags = F_set_buffer_offset | F_set_position;
388 i.buffer_offset = buf_offset;
389 i.buffer_index = 0;
390 i.view_index = 0;
391 i.bytes_per_line = 0;
393 i.xpos = scr_x;
394 i.ypos = scr_y;
395 i.width = w;
396 i.height = h;
397 return set_info(i);
398}
399
400}}
L4::Cap related definitions.
Class that abstracts framebuffers.
Definition goos:225
Flags
Flags for a Goos.
Definition goos:229
int create_view(View *view, l4_utcb_t *utcb=l4_utcb()) const noexcept
Create a view.
Definition goos:312
View view(unsigned index) const noexcept
Return a view.
Definition goos:363
int delete_view(View const &v, l4_utcb_t *utcb=l4_utcb()) const noexcept
Delete a view.
Definition goos:332
Pixel information.
Definition colors:95
void dump(OUT &s) const
Dump information on the pixel to a stream.
Definition colors:246
View of a framebuffer.
Definition goos:40
int set_info(Info const &info) const noexcept
Set the information structure for this view.
Definition goos:371
V_flags
Property flags of a view.
Definition goos:83
int push_bottom() const noexcept
Push this view the back.
Definition goos:189
int info(Info *info) const noexcept
Return the view information of the view.
Definition goos:367
bool valid() const
Return whether this view is valid.
Definition goos:205
Flags
Flags on a view.
Definition goos:60
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
int refresh(int x, int y, int w, int h) const noexcept
Refresh/Redraw the view.
Definition goos:379
int stack(View const &pivot, bool behind=true) const noexcept
Move this view in the view stack.
Definition goos:375
bool is_valid() const noexcept
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
Definition capability.h:57
C++ interface for capabilities.
Definition capability.h:219
Helper class to create an L4Re interface class that is derived from a single base class.
Definition __typeinfo.h:750
Dataspace interface.
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:335
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
#define L4_EXPORT
Attribute to mark functions, variables, and data types as being exported from a library.
Definition compiler.h:210
Interface Definition Language.
#define L4_INLINE_RPC(res, name, args, attr...)
Define an inline RPC call (type and callable).
Definition ipc_iface:476
#define L4_RPC(res, name, args, attr...)
Define an RPC call (type and callable).
Definition ipc_iface:535
#define L4_INLINE_RPC_NF(res, name, args...)
Define an inline RPC call type (the type only, no callable).
Definition ipc_iface:447
L4Re C++ Interfaces.
Definition cmd_control:14
Information structure of a Goos.
Definition goos:238
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
unsigned long height
Height.
Definition goos:240
unsigned long width
Width.
Definition goos:239
Pixel_info pixel_info
Pixel information.
Definition goos:244
bool has_dynamic_buffers() const
Return whether dynamic buffers are supported.
Definition goos:254
bool has_pointer() const
Return whether a pointer is used by the provider of the Goos.
Definition goos:250
bool has_dynamic_views() const
Return whether dynamic view are supported.
Definition goos:252
unsigned flags
Flags, see Flags.
Definition goos:241
unsigned num_static_buffers
Number of static buffers.
Definition goos:243
unsigned num_static_views
Number of static view.
Definition goos:242
Information structure of a view.
Definition goos:92
Pixel_info pixel_info
Pixel information.
Definition goos:102
unsigned long height
Height of the view in pixels.
Definition goos:99
unsigned long width
Width of the view in pixels.
Definition goos:98
bool has_set_buffer() const
Return whether a buffer is set.
Definition goos:111
unsigned buffer_index
Number of the buffer used for this view.
Definition goos:103
unsigned long xpos
X position in pixels of the view in the Goos.
Definition goos:96
unsigned view_index
Index of the view.
Definition goos:94
unsigned long buffer_offset
Offset in the memory buffer in bytes.
Definition goos:100
bool has_set_pixel() const
Return whether the given pixel information is valid.
Definition goos:117
unsigned long bytes_per_line
Bytes per line.
Definition goos:101
bool has_static_buffer() const
Return whether the view has a static buffer.
Definition goos:106
void dump(OUT &s) const
Dump information on the view information to a stream.
Definition goos:123
bool has_set_buffer_offset() const
Return whether the given buffer offset is valid.
Definition goos:113
unsigned long ypos
Y position in pixels of the view in the Goos.
Definition goos:97
bool has_set_bytes_per_line() const
Return whether the given bytes-per-line value is valid.
Definition goos:115
unsigned flags
Flags, see Flags and V_flags.
Definition goos:93
bool has_static_buffer_offset() const
Return whether the static buffer offset is available.
Definition goos:108
bool has_set_position() const
Return whether the position information given is valid.
Definition goos:119
Mark an argument as a output value in an RPC signature.
Definition ipc_types:31
Standard list of RPCs of an interface.
Definition __typeinfo.h:428