libs: re-indent all source code related to VA utilities.
[platform/upstream/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapiutils_glx.h
1 /*
2  *  gstvaapiutils_glx.h - GLX utilties
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6  *  Copyright (C) 2012 Intel Corporation
7  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation; either version 2.1
12  *  of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free
21  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA 02110-1301 USA
23  */
24
25 #ifndef GST_VAAPI_UTILS_GLX_H
26 #define GST_VAAPI_UTILS_GLX_H
27
28 #include "config.h"
29 #include "libgstvaapi_priv_check.h"
30 #include <GL/gl.h>
31 #include <GL/glext.h>
32 #include <GL/glx.h>
33 #include <GL/glxext.h>
34 #include <glib.h>
35
36 #if GLX_GLXEXT_VERSION < 18
37 typedef void (*PFNGLXBINDTEXIMAGEEXTPROC) (Display *, GLXDrawable, int,
38     const int *);
39 typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC) (Display *, GLXDrawable, int);
40 #endif
41
42 #if GLX_GLXEXT_VERSION < 27
43 /* XXX: this is not exactly that version but this is the only means to
44    make sure we have the correct <GL/glx.h> with those signatures */
45 typedef GLXPixmap (*PFNGLXCREATEPIXMAPPROC) (Display *, GLXFBConfig, Pixmap,
46     const int *);
47 typedef void (*PFNGLXDESTROYPIXMAPPROC) (Display *, GLXPixmap);
48 #endif
49
50 #ifndef GL_FRAMEBUFFER_BINDING
51 #define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
52 #endif
53
54 G_GNUC_INTERNAL
55 const gchar *
56 gl_get_error_string (GLenum error);
57
58 G_GNUC_INTERNAL
59 void
60 gl_purge_errors (void);
61
62 G_GNUC_INTERNAL
63 gboolean
64 gl_check_error (void);
65
66 G_GNUC_INTERNAL
67 gboolean
68 gl_get_param (GLenum param, guint * pval);
69
70 G_GNUC_INTERNAL
71 gboolean
72 gl_get_texture_param (GLenum target, GLenum param, guint * pval);
73
74 G_GNUC_INTERNAL
75 void
76 gl_set_bgcolor (guint32 color);
77
78 G_GNUC_INTERNAL
79 void
80 gl_resize (guint width, guint height);
81
82 typedef struct _GLContextState GLContextState;
83 struct _GLContextState
84 {
85   Display *display;
86   Window window;
87   XVisualInfo *visual;
88   GLXContext context;
89   guint swapped_buffers:1;
90 };
91
92 G_GNUC_INTERNAL
93 GLContextState *
94 gl_create_context (Display * dpy, int screen, GLContextState * parent);
95
96 G_GNUC_INTERNAL
97 void
98 gl_destroy_context (GLContextState * cs);
99
100 G_GNUC_INTERNAL
101 void
102 gl_get_current_context (GLContextState * cs);
103
104 G_GNUC_INTERNAL
105 gboolean
106 gl_set_current_context (GLContextState * new_cs, GLContextState * old_cs);
107
108 G_GNUC_INTERNAL
109 void
110 gl_swap_buffers (GLContextState * cs);
111
112 typedef struct _GLTextureState GLTextureState;
113 struct _GLTextureState
114 {
115   GLenum target;
116   GLuint old_texture;
117   guint was_enabled:1;
118   guint was_bound:1;
119 };
120
121 G_GNUC_INTERNAL
122 gboolean
123 gl_bind_texture (GLTextureState * ts, GLenum target, GLuint texture);
124
125 G_GNUC_INTERNAL
126 void
127 gl_unbind_texture (GLTextureState * ts);
128
129 G_GNUC_INTERNAL
130 GLuint
131 gl_create_texture (GLenum target, GLenum format, guint width, guint height);
132
133 typedef struct _GLVTable GLVTable;
134 struct _GLVTable
135 {
136   PFNGLXCREATEPIXMAPPROC glx_create_pixmap;
137   PFNGLXDESTROYPIXMAPPROC glx_destroy_pixmap;
138   PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image;
139   PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image;
140   PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers;
141   PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers;
142   PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer;
143   PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers;
144   PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers;
145   PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer;
146   PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage;
147   PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer;
148   PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d;
149   PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status;
150   guint has_texture_from_pixmap:1;
151   guint has_framebuffer_object:1;
152 };
153
154 G_GNUC_INTERNAL
155 GLVTable *
156 gl_get_vtable (void);
157
158 typedef struct _GLPixmapObject GLPixmapObject;
159 struct _GLPixmapObject
160 {
161   Display *dpy;
162   GLenum target;
163   GLuint texture;
164   GLTextureState old_texture;
165   guint width;
166   guint height;
167   Pixmap pixmap;
168   GLXPixmap glx_pixmap;
169   guint is_bound:1;
170 };
171
172 G_GNUC_INTERNAL
173 GLPixmapObject *
174 gl_create_pixmap_object (Display * dpy, guint width, guint height);
175
176 G_GNUC_INTERNAL
177 void
178 gl_destroy_pixmap_object (GLPixmapObject * pixo);
179
180 G_GNUC_INTERNAL
181 gboolean
182 gl_bind_pixmap_object (GLPixmapObject * pixo);
183
184 G_GNUC_INTERNAL
185 gboolean
186 gl_unbind_pixmap_object (GLPixmapObject * pixo);
187
188 typedef struct _GLFramebufferObject GLFramebufferObject;
189 struct _GLFramebufferObject
190 {
191   guint width;
192   guint height;
193   GLuint fbo;
194   GLuint old_fbo;
195   guint is_bound:1;
196 };
197
198 G_GNUC_INTERNAL
199 GLFramebufferObject *
200 gl_create_framebuffer_object (GLenum target,
201     GLuint texture, guint width, guint height);
202
203 G_GNUC_INTERNAL
204 void
205 gl_destroy_framebuffer_object (GLFramebufferObject * fbo);
206
207 G_GNUC_INTERNAL
208 gboolean
209 gl_bind_framebuffer_object (GLFramebufferObject * fbo);
210
211 G_GNUC_INTERNAL
212 gboolean
213 gl_unbind_framebuffer_object (GLFramebufferObject * fbo);
214
215 #endif /* GST_VAAPI_UTILS_GLX_H */