1 /*
2  * GTK VNC Widget
3  *
4  * Copyright (C) 2006  Anthony Liguori <anthony@codemonkey.ws>
5  * Copyright (C) 2009-2010 Daniel P. Berrange <dan@berrange.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.0 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
20  */
21 
22 #include <config.h>
23 
24 #include "vncframebuffer.h"
25 
26 /**
27  * vnc_framebuffer_get_width:
28  * @fb: (transfer none): the framebuffer object
29  *
30  * Query the width of the remote framebuffer
31  *
32  * Returns: the framebuffer width
33  */
vnc_framebuffer_get_width(VncFramebuffer * fb)34 guint16 vnc_framebuffer_get_width(VncFramebuffer *fb)
35 {
36     return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_width(fb);
37 }
38 
39 /**
40  * vnc_framebuffer_get_height:
41  * @fb: (transfer none): the framebuffer object
42  *
43  * Query the height of the remote framebuffer
44  *
45  * Returns: the frambuffer height
46  */
vnc_framebuffer_get_height(VncFramebuffer * fb)47 guint16 vnc_framebuffer_get_height(VncFramebuffer *fb)
48 {
49     return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_height(fb);
50 }
51 
52 /**
53  * vnc_framebuffer_get_rowstride:
54  * @fb: (transfer none): the framebuffer object
55  *
56  * Get the number of bytes per line of the framebuffer
57  *
58  * Returns: the framebuffer row stride
59  */
vnc_framebuffer_get_rowstride(VncFramebuffer * fb)60 int vnc_framebuffer_get_rowstride(VncFramebuffer *fb)
61 {
62     return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_rowstride(fb);
63 }
64 
65 /**
66  * vnc_framebuffer_get_buffer:
67  * @fb: (transfer none): the framebuffer object
68  *
69  * Get a pointer to the framebuffer contents
70  *
71  * Returns: (transfer none)(array): the framebuffer data
72  */
vnc_framebuffer_get_buffer(VncFramebuffer * fb)73 guint8 *vnc_framebuffer_get_buffer(VncFramebuffer *fb)
74 {
75     return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_buffer(fb);
76 }
77 
78 /**
79  * vnc_framebuffer_get_local_format:
80  * @fb: (transfer none): the framebuffer object
81  *
82  * Get the pixel format used to store the framebuffer locally
83  *
84  * Returns: (transfer none): the local pixel format
85  */
vnc_framebuffer_get_local_format(VncFramebuffer * fb)86 const VncPixelFormat *vnc_framebuffer_get_local_format(VncFramebuffer *fb)
87 {
88     return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_local_format(fb);
89 }
90 
91 /**
92  * vnc_framebuffer_remote_format:
93  * @fb: (transfer none): the framebuffer object
94  *
95  * Get the pixel format used by the remote desktop sending
96  * framebuffer updates.
97  *
98  * Returns: (transfer none): the remote pixel format
99  */
vnc_framebuffer_get_remote_format(VncFramebuffer * fb)100 const VncPixelFormat *vnc_framebuffer_get_remote_format(VncFramebuffer *fb)
101 {
102     return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->get_remote_format(fb);
103 }
104 
105 /**
106  * vnc_framebuffer_perfect_format_match:
107  * @fb: (transfer none): the framebuffer object
108  *
109  * Determine if the local and remote pixel formats match
110  *
111  * Returns: TRUE if the local and remote pixel formats match
112  */
vnc_framebuffer_perfect_format_match(VncFramebuffer * fb)113 gboolean vnc_framebuffer_perfect_format_match(VncFramebuffer *fb)
114 {
115     return VNC_FRAMEBUFFER_GET_INTERFACE(fb)->perfect_format_match(fb);
116 }
117 
118 /**
119  * vnc_framebuffer_set_pixel_at:
120  * @fb: (transfer none): the framebuffer object
121  * @src: (array)(transfer none): the new pixel data
122  * @x: the horizontal pixel to set
123  * @y: the vertical pixel to set
124  *
125  * Sets a pixel in the framebuffer at (@x, @y) to the
126  * value in @src. The number of bytes in @src is
127  * determined by the remote pixel format
128  */
vnc_framebuffer_set_pixel_at(VncFramebuffer * fb,guint8 * src,guint16 x,guint16 y)129 void vnc_framebuffer_set_pixel_at(VncFramebuffer *fb,
130                                   guint8 *src,
131                                   guint16 x, guint16 y)
132 {
133     VNC_FRAMEBUFFER_GET_INTERFACE(fb)->set_pixel_at(fb, src, x, y);
134 }
135 
136 /**
137  * vnc_framebuffer_fill:
138  * @fb: (transfer none): the framebuffer object
139  * @src: (array)(transfer none): the new pixel data
140  * @x: the horizontal pixel to start filling
141  * @y: the vertical pixel to start filling
142  * @width: the number of pixels to fill horizontally
143  * @height: the number of pixels to fill vertically
144  *
145  * Fill all the pixels in the range (@x, @y) to
146  * (@x + @width, @y + @height) to the value in
147  * @src. The number of bytes in @src is
148  * determined by the remote pixel format
149  */
vnc_framebuffer_fill(VncFramebuffer * fb,guint8 * src,guint16 x,guint16 y,guint16 width,guint16 height)150 void vnc_framebuffer_fill(VncFramebuffer *fb,
151                           guint8 *src,
152                           guint16 x, guint16 y,
153                           guint16 width, guint16 height)
154 {
155     VNC_FRAMEBUFFER_GET_INTERFACE(fb)->fill(fb, src, x, y, width, height);
156 }
157 
158 /**
159  * vnc_framebuffer_copyrect:
160  * @fb: (transfer none): the framebuffer object
161  * @srcx: the horizontal starting pixel
162  * @srcy: the vertical starting pixel
163  * @dstx: the horizontal target pixel
164  * @dsty: the vertical target pixel
165  * @width: the width of the region
166  * @height: the height of the region
167  *
168  * Copies data from the range (@srcx, @srcy) to
169  * (@srcx+@width, @srcy+@height) over to the
170  * range starting at (@dstx, @dsty).
171  */
vnc_framebuffer_copyrect(VncFramebuffer * fb,guint16 srcx,guint16 srcy,guint16 dstx,guint16 dsty,guint16 width,guint16 height)172 void vnc_framebuffer_copyrect(VncFramebuffer *fb,
173                               guint16 srcx, guint16 srcy,
174                               guint16 dstx, guint16 dsty,
175                               guint16 width, guint16 height)
176 {
177     VNC_FRAMEBUFFER_GET_INTERFACE(fb)->copyrect(fb, srcx, srcy, dstx, dsty, width, height);
178 }
179 
180 /**
181  * vnc_framebuffer_:
182  * @fb: (transfer none): the framebuffer object
183  * @src: (array)(transfer none): the new pixel data
184  * @rowstride: the number of bytes per row
185  * @x: the horizontal pixel to start filling
186  * @y: the vertical pixel to start filling
187  * @width: the number of pixels to fill horizontally
188  * @height: the number of pixels to fill vertically
189  *
190  * Fill all the pixels in the range (@x, @y) to
191  * (@x + @width, @y + @height) to the value in
192  * @src. The number of bytes in @src is
193  * determined by the remote pixel format
194  */
vnc_framebuffer_blt(VncFramebuffer * fb,guint8 * src,int rowstride,guint16 x,guint16 y,guint16 width,guint16 height)195 void vnc_framebuffer_blt(VncFramebuffer *fb,
196                          guint8 *src,
197                          int rowstride,
198                          guint16 x, guint16 y,
199                          guint16 width, guint16 height)
200 {
201     VNC_FRAMEBUFFER_GET_INTERFACE(fb)->blt(fb, src, rowstride, x, y, width, height);
202 }
203 
204 /**
205  * vnc_framebuffer_rgb24_blt:
206  * @fb: (transfer none): the framebuffer object
207  * @src: (array)(transfer none): the new pixel data
208  * @rowstride: the number of bytes per row
209  * @x: the horizontal pixel to start filling
210  * @y: the vertical pixel to start filling
211  * @width: the number of pixels to fill horizontally
212  * @height: the number of pixels to fill vertically
213  *
214  * Fill all the pixels in the range (@x, @y) to
215  * (@x + @width, @y + @height) to the value in
216  * @src. The number of bytes in @src is always
217  * 3 as it must be in plain RGB24 format.
218  */
vnc_framebuffer_rgb24_blt(VncFramebuffer * fb,guint8 * src,int rowstride,guint16 x,guint16 y,guint16 width,guint16 height)219 void vnc_framebuffer_rgb24_blt(VncFramebuffer *fb,
220                                guint8 *src,
221                                int rowstride,
222                                guint16 x, guint16 y,
223                                guint16 width, guint16 height)
224 {
225     VNC_FRAMEBUFFER_GET_INTERFACE(fb)->rgb24_blt(fb, src, rowstride, x, y, width, height);
226 }
227 
228 
229 /**
230  * vnc_framebuffer_set_color_map:
231  * @fb: (transfer none): the framebuffer object
232  * @map: (transfer none): the new color map
233  *
234  * Set the color map to use for the framebuffer
235  */
vnc_framebuffer_set_color_map(VncFramebuffer * fb,VncColorMap * map)236 void vnc_framebuffer_set_color_map(VncFramebuffer *fb,
237                                    VncColorMap *map)
238 {
239     VNC_FRAMEBUFFER_GET_INTERFACE(fb)->set_color_map(fb, map);
240 }
241 
242 
243 GType
vnc_framebuffer_get_type(void)244 vnc_framebuffer_get_type (void)
245 {
246     static GType framebuffer_type = 0;
247 
248     if (!framebuffer_type) {
249         framebuffer_type =
250             g_type_register_static_simple (G_TYPE_INTERFACE, "VncFramebuffer",
251                                            sizeof (VncFramebufferInterface),
252                                            NULL, 0, NULL, 0);
253 
254         g_type_interface_add_prerequisite (framebuffer_type, G_TYPE_OBJECT);
255     }
256 
257     return framebuffer_type;
258 }
259 
260 
261 /*
262  * Local variables:
263  *  c-indent-level: 4
264  *  c-basic-offset: 4
265  *  indent-tabs-mode: nil
266  * End:
267  */
268