]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re/include/video/goos
update
[l4.git] / l4 / pkg / l4re / include / video / goos
1 // vi:ft=cpp:
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  * This file is part of TUD:OS and distributed under the terms of the
8  * GNU General Public License 2.
9  * Please see the COPYING-GPL-2 file for details.
10  *
11  * As a special exception, you may use this file as part of a free software
12  * library without restriction.  Specifically, if other files instantiate
13  * templates or use macros or inline functions from this file, or you compile
14  * this file and link it with other files to produce an executable, this
15  * file does not by itself cause the resulting executable to be covered by
16  * the GNU General Public License.  This exception does not however
17  * invalidate any other reasons why the executable file might be covered by
18  * the GNU General Public License.
19  */
20 #pragma once
21
22 #include <l4/sys/capability>
23 #include <l4/re/dataspace>
24 #include <l4/re/video/colors>
25 #include <l4/re/video/view>
26
27 namespace L4Re { namespace Video {
28
29 /**
30  * \defgroup api_l4re_goos Goos video API
31  * \ingroup api_l4re
32  */
33
34
35 /**
36  * \brief A goos.
37  * \ingroup api_l4re_goos
38  */
39 class L4_EXPORT Goos :
40   public L4::Kobject_t<Goos, L4::Kobject, L4Re::Protocol::Goos>
41 {
42   L4_KOBJECT_DISABLE_COPY(Goos)
43
44 public:
45   /** Flags for a goos */
46   enum Flags
47   {
48     F_auto_refresh    = 0x01, ///< The graphics display is automatically refreshed
49     F_pointer         = 0x02, ///< We have a mouse pointer
50     F_dynamic_views   = 0x04, ///< Supports dynamically allocated views
51     F_dynamic_buffers = 0x08, ///< Supports dynamically allocated buffers
52   };
53
54   /** Information structure of a goos */
55   struct Info
56   {
57     unsigned long width;          ///< Width
58     unsigned long height;         ///< Height
59     unsigned flags;               ///< Flags, see \a Flags
60     unsigned num_static_views;    ///< Number of static view
61     unsigned num_static_buffers;  ///< Number of static buffers
62     Pixel_info pixel_info;        ///< Pixel information
63
64     /** Return whether this goos does auto refreshing or the view refresh
65      * functions must be used to make changes visible. */
66     bool auto_refresh() const { return flags & F_auto_refresh; }
67     /** Return whether a pointer is used by the provider of the goos */
68     bool has_pointer() const { return flags & F_pointer; }
69     /** Return whether dynamic view are supported */
70     bool has_dynamic_views() const { return flags & F_dynamic_views; }
71     /** Return whether dynamic buffers are supported */
72     bool has_dynamic_buffers() const { return flags & F_dynamic_buffers; }
73   };
74
75   /**
76    * \brief Return the goos information of the goos.
77    * \retval info   Goos information structure pointer.
78    * \return 0 on success, error otherwise
79    */
80   int info(Info *) const throw();
81
82   /**
83    * \brief Return a static buffer of a goos.
84    * \param idx     Index of the static buffer.
85    * \param rbuf    Capability slot to point the buffer dataspace to.
86    * \return 0 on success, error otherwise
87    */
88   int get_static_buffer(unsigned idx, L4::Cap<L4Re::Dataspace> rbuf) const throw();
89
90   /**
91    * \brief Create a buffer.
92    * \param size     Size of buffer in bytes.
93    * \param rbuf     Capability slot to point the buffer dataspace to.
94    * \return Positive: buffer index, negative: Error code
95    */
96   int create_buffer(unsigned long size, L4::Cap<L4Re::Dataspace> rbuf) const throw();
97
98   /**
99    * \brief Delete a buffer.
100    * \param idx      Buffer to delete.
101    * \return 0 on success, error otherwise
102    */
103   int delete_buffer(unsigned idx) const throw();
104
105   /**
106    * \brief Create a view.
107    * \retval view   A view object.
108    * \return Positive: view index, negative: Error code
109    */
110   int create_view(View *view) const throw();
111
112   /**
113    * \brief Delete a view.
114    * \param  v  The view object to delete.
115    * \return 0 on success, error otherwise
116    */
117   int delete_view(View const &v) const throw();
118
119   /**
120    * \brief Return a view.
121    * \param index   Index of the view to return.
122    * \return The view.
123    */
124   View view(unsigned index) const throw();
125 };
126
127 inline View
128 Goos::view(unsigned index) const throw()
129 { return View(cap(), index); }
130
131 }}