1 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3    Copyright (C) 2010 Red Hat, Inc.
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef __SPICE_CLIENT_DISPLAY_CHANNEL_H__
19 #define __SPICE_CLIENT_DISPLAY_CHANNEL_H__
20 
21 #if !defined(__SPICE_CLIENT_H_INSIDE__) && !defined(SPICE_COMPILATION)
22 #warning "Only <spice-client.h> can be included directly"
23 #endif
24 
25 #include "spice-client.h"
26 
27 G_BEGIN_DECLS
28 
29 #define SPICE_TYPE_DISPLAY_CHANNEL            (spice_display_channel_get_type())
30 #define SPICE_DISPLAY_CHANNEL(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), SPICE_TYPE_DISPLAY_CHANNEL, SpiceDisplayChannel))
31 #define SPICE_DISPLAY_CHANNEL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SPICE_TYPE_DISPLAY_CHANNEL, SpiceDisplayChannelClass))
32 #define SPICE_IS_DISPLAY_CHANNEL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), SPICE_TYPE_DISPLAY_CHANNEL))
33 #define SPICE_IS_DISPLAY_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SPICE_TYPE_DISPLAY_CHANNEL))
34 #define SPICE_DISPLAY_CHANNEL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), SPICE_TYPE_DISPLAY_CHANNEL, SpiceDisplayChannelClass))
35 
36 typedef struct _SpiceDisplayChannel SpiceDisplayChannel;
37 typedef struct _SpiceDisplayChannelClass SpiceDisplayChannelClass;
38 typedef struct _SpiceDisplayChannelPrivate SpiceDisplayChannelPrivate;
39 
40 #define SPICE_TYPE_GL_SCANOUT (spice_gl_scanout_get_type ())
41 
42 /**
43  * SpiceGlScanout:
44  * @fd: a drm DMABUF file that can be imported with eglCreateImageKHR
45  * @width: width of the scanout
46  * @height: height of the scanout
47  * @stride: stride of the scanout
48  * @format: the drm fourcc format
49  * @y0top: orientation of the scanout
50  *
51  * Holds the information necessary for using the GL display scanout.
52  **/
53 typedef struct _SpiceGlScanout SpiceGlScanout;
54 struct _SpiceGlScanout {
55     gint fd;
56     guint32 width;
57     guint32 height;
58     guint32 stride;
59     guint32 format;
60     gboolean y0top;
61 };
62 
63 /**
64  * SpiceDisplayMonitorConfig:
65  * @id: monitor id
66  * @surface_id: monitor surface id
67  * @x: x position of the monitor
68  * @y: y position of the monitor
69  * @width: width of the monitor
70  * @height: height of the monitor
71  *
72  * Holds a monitor configuration.
73  **/
74 typedef struct _SpiceDisplayMonitorConfig SpiceDisplayMonitorConfig;
75 struct _SpiceDisplayMonitorConfig {
76     guint id;
77     guint surface_id;
78     guint x;
79     guint y;
80     guint width;
81     guint height;
82 };
83 
84 /**
85  * SpiceDisplayPrimary:
86  * @format: primary buffer format
87  * @width: width of the primary
88  * @height: height of the primary
89  * @stride: stride of the primary
90  * @shmid: identifier of the shared memory segment associated with
91  * the @data, or -1 if not shm
92  * @data: pointer to primary buffer
93  * @marked: whether the display is marked ready
94  *
95  * Holds the information necessary to use the primary surface.
96  **/
97 typedef struct _SpiceDisplayPrimary SpiceDisplayPrimary;
98 struct _SpiceDisplayPrimary {
99     enum SpiceSurfaceFmt format;
100     gint width;
101     gint height;
102     gint stride;
103     gint shmid;
104     guint8 *data;
105     gboolean marked;
106 };
107 
108 /**
109  * SpiceDisplayChannel:
110  *
111  * The #SpiceDisplayChannel struct is opaque and should not be accessed directly.
112  */
113 struct _SpiceDisplayChannel {
114     SpiceChannel parent;
115 
116     /*< private >*/
117     SpiceDisplayChannelPrivate *priv;
118     /* Do not add fields to this struct */
119 };
120 
121 /**
122  * SpiceDisplayChannelClass:
123  * @parent_class: Parent class.
124  * @display_primary_create: Signal class handler for the #SpiceDisplayChannel::display-primary-create signal.
125  * @display_primary_destroy: Signal class handler for the #SpiceDisplayChannel::display-primary-destroy signal.
126  * @display_invalidate: Signal class handler for the #SpiceDisplayChannel::display-invalidate signal.
127  * @display_mark: Signal class handler for the #SpiceDisplayChannel::display-mark signal.
128  *
129  * Class structure for #SpiceDisplayChannel.
130  */
131 struct _SpiceDisplayChannelClass {
132     SpiceChannelClass parent_class;
133 
134     /* signals */
135     void (*display_primary_create)(SpiceChannel *channel, gint format,
136                                    gint width, gint height, gint stride,
137                                    gint shmid, gpointer data);
138     void (*display_primary_destroy)(SpiceChannel *channel);
139     void (*display_invalidate)(SpiceChannel *channel,
140                                gint x, gint y, gint w, gint h);
141     void (*display_mark)(SpiceChannel *channel,
142                          gboolean mark);
143 
144     /*< private >*/
145 };
146 
147 GType	        spice_display_channel_get_type(void);
148 gboolean        spice_display_channel_get_primary(SpiceChannel *channel, guint32 surface_id,
149                                                   SpiceDisplayPrimary *primary);
150 
151 void spice_display_channel_change_preferred_compression(SpiceChannel *channel, gint compression);
152 void spice_display_channel_change_preferred_video_codec_type(SpiceChannel *channel, gint codec_type);
153 
154 GType           spice_gl_scanout_get_type     (void) G_GNUC_CONST;
155 void            spice_gl_scanout_free         (SpiceGlScanout *scanout);
156 
157 const SpiceGlScanout* spice_display_channel_get_gl_scanout(SpiceDisplayChannel *channel);
158 void spice_display_channel_gl_draw_done(SpiceDisplayChannel *channel);
159 
160 #ifndef SPICE_DISABLE_DEPRECATED
161 G_DEPRECATED_FOR(spice_display_channel_change_preferred_compression)
162 void spice_display_change_preferred_compression(SpiceChannel *channel, gint compression);
163 G_DEPRECATED_FOR(spice_display_channel_change_preferred_video_codec_type)
164 void spice_display_change_preferred_video_codec_type(SpiceChannel *channel, gint codec_type);
165 G_DEPRECATED_FOR(spice_display_channel_get_gl_scanout)
166 const SpiceGlScanout* spice_display_get_gl_scanout(SpiceDisplayChannel *channel);
167 G_DEPRECATED_FOR(spice_display_channel_get_primary)
168 gboolean spice_display_get_primary(SpiceChannel *channel, guint32 surface_id,
169                                    SpiceDisplayPrimary *primary);
170 G_DEPRECATED_FOR(spice_display_channel_gl_draw_done)
171 void spice_display_gl_draw_done(SpiceDisplayChannel *channel);
172 #endif
173 
174 G_END_DECLS
175 
176 #endif /* __SPICE_CLIENT_DISPLAY_CHANNEL_H__ */
177