]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re/lib/src/video/view.cc
Inital import
[l4.git] / l4 / pkg / l4re / lib / src / video / view.cc
1 /*
2  * (c) 2008-2009 Technische Universität Dresden
3  * This file is part of TUD:OS and distributed under the terms of the
4  * GNU General Public License 2.
5  * Please see the COPYING-GPL-2 file for details.
6  *
7  * As a special exception, you may use this file as part of a free software
8  * library without restriction.  Specifically, if other files instantiate
9  * templates or use macros or inline functions from this file, or you compile
10  * this file and link it with other files to produce an executable, this
11  * file does not by itself cause the resulting executable to be covered by
12  * the GNU General Public License.  This exception does not however
13  * invalidate any other reasons why the executable file might be covered by
14  * the GNU General Public License.
15  */
16
17 #include <l4/re/video/goos>
18 #include <l4/re/video/goos-sys.h>
19
20 #include <l4/re/dataspace>
21 #include <l4/re/protocols>
22
23 #include <l4/cxx/ipc_helper>
24 #include <l4/cxx/ipc_stream>
25
26 #include <l4/sys/err.h>
27
28
29 namespace L4Re { namespace Video {
30
31 using L4::Opcode;
32
33 int
34 View::info(Info *info) const throw()
35 {
36   L4::Ipc_iostream io(l4_utcb());
37   io << Opcode(Goos_::View_info) << _view_idx;
38   long err = l4_error(io.call(_goos.cap(), L4Re::Protocol::Goos));
39   if (EXPECT_FALSE(err < 0))
40     return err;
41
42   io.get(*info);
43   return err;
44 }
45
46 int
47 View::set_info(Info const &i) const throw()
48 {
49   L4::Ipc_iostream io(l4_utcb());
50   io << Opcode(Goos_::View_set_info) << _view_idx;
51   io.put(i);
52   return l4_error(io.call(_goos.cap(), L4Re::Protocol::Goos));
53 }
54
55 int
56 View::set_viewport(int scr_x, int scr_y, int w, int h,
57                    unsigned long buf_offset) const throw()
58 {
59   Info i;
60   i.flags = F_set_buffer_offset | F_set_position;
61   i.buffer_offset = buf_offset;
62   i.xpos = scr_x;
63   i.ypos = scr_y;
64   i.width = w;
65   i.height = h;
66   return set_info(i);
67 }
68
69 int
70 View::stack(View const &pivot, bool behind) const throw()
71 {
72   L4::Ipc_iostream io(l4_utcb());
73   io << Opcode(Goos_::View_stack) << _view_idx << pivot.view_index() << behind;
74   return l4_error(io.call(_goos.cap(), L4Re::Protocol::Goos));
75 }
76
77 int
78 View::refresh(int x, int y, int w, int h) const throw()
79 {
80   L4::Ipc_iostream io(l4_utcb());
81   io << Opcode(Goos_::View_refresh) << _view_idx;
82   io << x << y << w << h;
83   return l4_error(io.call(_goos.cap(), L4Re::Protocol::Goos));
84 }
85
86 }}