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)
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.
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.
22 #include <l4/sys/capability>
23 #include <l4/re/dataspace>
24 #include <l4/re/video/colors>
26 namespace L4Re { namespace Video {
32 * \ingroup api_l4re_goos
42 View(l4_cap_idx_t goos, unsigned idx) : _goos(goos), _view_idx(idx) {}
44 unsigned view_index() const throw()
45 { return _goos.is_valid() ? _view_idx : ~0U; }
48 View() : _goos(L4::Cap<Goos>::Invalid) {}
51 * \brief Flags on a view.
55 F_none = 0x00, ///< everything for this view is static (the VESA-FB case)
56 F_set_buffer = 0x01, ///< buffer object for this view can be changed
57 F_set_buffer_offset = 0x02, ///< buffer offset can be set
58 F_set_bytes_per_line = 0x04, ///< bytes per line can be set
59 F_set_pixel = 0x08, ///< pixel type can be set
60 F_set_position = 0x10, ///< position on screen can be set
61 F_dyn_allocated = 0x20, ///< View is dynamically allocated
62 F_set_background = 0x40, ///< Set view as background for session
63 F_set_flags = 0x80, ///< Set view flags (\see V_flags)
65 /** Flags for a fully dynamic view */
66 F_fully_dynamic = F_set_buffer | F_set_buffer_offset | F_set_bytes_per_line
67 | F_set_pixel | F_set_position | F_dyn_allocated,
71 * \brief Property flags of a view.
73 * Such flags can be set or deleted with the #F_set_flags operation using
74 * the set_info() method.
78 F_above = 0x1000, ///< Flag the view as stay on top
79 F_flags_mask = 0xff000, ///< Mask containing all possible property flags
83 * \brief Information structure of a view.
87 unsigned flags; ///< Flags, \see \a Flags and \a V_flags
88 unsigned view_index; ///< Index of the view
90 unsigned long xpos; ///< X position in pixels of the view in the goos
91 unsigned long ypos; ///< Y position in pixels of the view in the goos
92 unsigned long width; ///< Width of the view in pixels
93 unsigned long height; ///< Height of the view in pixels
94 unsigned long buffer_offset; ///< Offset in the memory buffer in bytes
95 unsigned long bytes_per_line; ///< Bytes per line
96 Pixel_info pixel_info; ///< Pixel information
97 unsigned buffer_index; ///< Number of the buffer used for this view
99 /** Return whether the view has a static buffer */
100 bool has_static_buffer() const { return !(flags & F_set_buffer); }
101 /** Return whether the static buffer offset is available */
102 bool has_static_buffer_offset() const { return !(flags & F_set_buffer_offset); }
104 /** Return whether a buffer is set */
105 bool has_set_buffer() const { return flags & F_set_buffer; }
106 /** Return whether the given buffer offset is valid */
107 bool has_set_buffer_offset() const { return flags & F_set_buffer_offset; }
108 /** Return whether the given bytes-per-line value is valid */
109 bool has_set_bytes_per_line() const { return flags & F_set_bytes_per_line; }
110 /** Return whether the given pixel information is valid */
111 bool has_set_pixel() const { return flags & F_set_pixel; }
112 /** Return whether the position information given is valid */
113 bool has_set_position() const { return flags & F_set_position; }
115 /** Dump information on the view information to a stream */
116 template< typename STREAM >
117 STREAM &dump(STREAM &s) const
119 s << "View::Info:" << '\n'
120 << " flags: " << flags << '\n'
121 << " size: " << (int)width << 'x' << (int)height
122 << " pos: " << (int)xpos << ", " << (int)ypos << '\n'
123 << " bytes_per_line: " << bytes_per_line << '\n'
124 << " buffer_offset: " << buffer_offset << '\n'
126 pixel_info.dump(s) << '\n';
132 * \brief Return the view information of the view.
133 * \retval info Information structure pointer.
134 * \return 0 on success, error otherwise
136 int info(Info *info) const throw();
139 * \brief Set the information structure for this view.
140 * \param info Information structure.
141 * \return 0 on success, error otherwise
143 * The function will also set the view port according to the values given
144 * in the information structure.
146 int set_info(Info const &info) const throw();
149 * \brief Set the position of the view in the goos.
150 * \param scr_x X position
151 * \param scr_y Y position
154 * \param buf_offset Offset in the buffer in bytes
155 * \return 0 on success, error otherwise
157 int set_viewport(int scr_x, int scr_y, int w, int h, unsigned long buf_offset) const throw();
160 * \brief Move this view in the view stack.
161 * \param pivot View to move relative to
162 * \param behind When true move the view behind the pivit view, if false
163 * move the view before the pivot view.
164 * \return 0 on success, error otherwise
166 int stack(View const &pivot, bool behind = true) const throw();
168 /** Make this view the top-most view */
169 int push_top() const throw()
170 { return stack(View(), true); }
172 /** Push this view the back */
173 int push_bottom() const throw()
174 { return stack(View(), false); }
177 * \brief Refresh/Redraw the view.
178 * \param x X position.
179 * \param y Y position.
182 * \return 0 on success, error otherwise
184 int refresh(int x, int y, int w, int h) const throw();
186 /** \brief Return whether this view is valid */
187 bool valid() const { return _goos.is_valid(); }