xine-lib 1.2.12
xine_gl.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2022 the xine project
3 * Copyright (C) 2018-2021 Petri Hintukainen <phintuka@users.sourceforge.net>
4 *
5 * This file is part of xine, a free video player.
6 *
7 * xine is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * xine 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
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 * xine_gl.h, Interface between OpenGL and native windowing system
22 *
23 * GL provider API, used in vo drivers
24 *
25 */
26
27#ifndef XINE_GL_H_
28#define XINE_GL_H_
29
30#include <stdlib.h>
31#include <string.h>
32
33#include <xine.h>
34#include <xine/sorted_array.h>
35
36typedef struct xine_gl xine_gl_t;
37
38struct xine_gl {
42
43 /* resize is needed only with WAYLAND visual */
44 void (*resize) (xine_gl_t *, int width, int height);
45 /* set_native_window is used only with X11 */
46 void (*set_native_window)(xine_gl_t *, void *);
47
48 void (*dispose) (xine_gl_t **);
49
50 void *(*get_proc_address)(xine_gl_t *, const char *);
51 const char * (*query_extensions)(xine_gl_t *);
52
53 /* EGL */
54 void * (*eglCreateImageKHR) (xine_gl_t *,
55 unsigned /* EGLenum target */,
56 void * /* EGLClientBuffer buffer */,
57 const int32_t * /*const EGLint * attrib_list */);
58 int (*eglDestroyImageKHR) (xine_gl_t *, void *);
59};
60
61xine_gl_t *_x_load_gl(xine_t *xine, unsigned visual_type, const void *visual, unsigned flags);
62
63
64static inline int _x_gl_has_extension(const char *extensions, const char * const ext) {
65 if (extensions)
66 while (*extensions) {
67 const char *p = ext;
68 while (*extensions == ' ') extensions++;
69 while (*p && *p == *extensions) p++, extensions++;
70 if (*p == 0 && (*extensions == 0 || *extensions == ' '))
71 return 1;
72 while (*extensions && *extensions != ' ')
73 extensions++;
74 }
75 return 0;
76}
77
78/* flags */
79#define XINE_GL_API_OPENGL 0x0001
80#define XINE_GL_API_OPENGLES 0x0002
81
82typedef struct {
84 unsigned char *buf;
86
89 free (e->buf);
90 e->list = NULL;
91 e->buf = NULL;
92}
93
94static inline void xine_gl_extensions_load (xine_gl_extensions_t *e, const char *list) {
95 size_t llen;
96 unsigned char *p;
97
98 e->list = NULL;
99 e->buf = NULL;
100 if (!list)
101 return;
102
103 llen = strlen (list) + 1;
104 e->buf = malloc (llen);
105 /* TJ. I got 298 strings here :-) */
106 e->list = xine_sarray_new (1024, (xine_sarray_comparator_t)strcmp);
107 if (!e->list || !e->buf) {
109 return;
110 }
111
112 p = e->buf;
113 memcpy (p, list, llen);
114 while (*p) {
115 unsigned char *q = p;
116 while (*p > ' ')
117 p++;
118 if (*p)
119 *p++ = 0;
120 if (*q)
121 xine_sarray_add (e->list, q);
122 }
123}
124
125static inline int xine_gl_extensions_test (xine_gl_extensions_t *e, const char *name) {
126 return xine_sarray_binary_search (e->list, (void *)name) >= 0;
127}
128
129#endif /* XINE_GL_H_ */
unsigned int height
Definition: gfontrle.c:5
unsigned int width
Definition: gfontrle.c:4
int xine_sarray_binary_search(xine_sarray_t *sarray, void *key)
Definition: sorted_array.c:101
void xine_sarray_delete(xine_sarray_t *sarray)
Definition: sorted_array.c:132
int xine_sarray_add(xine_sarray_t *sarray, void *value)
Definition: sorted_array.c:278
xine_sarray_t * xine_sarray_new(size_t initial_size, xine_sarray_comparator_t comparator)
Definition: sorted_array.c:111
int(* xine_sarray_comparator_t)(void *, void *)
Definition: sorted_array.h:67
Definition: xine_gl.h:82
unsigned char * buf
Definition: xine_gl.h:84
xine_sarray_t * list
Definition: xine_gl.h:83
Definition: xine_gl.h:38
void(* resize)(xine_gl_t *, int width, int height)
Definition: xine_gl.h:44
int(* make_current)(xine_gl_t *)
Definition: xine_gl.h:39
void(* swap_buffers)(xine_gl_t *)
Definition: xine_gl.h:41
void(* release_current)(xine_gl_t *)
Definition: xine_gl.h:40
int(* eglDestroyImageKHR)(xine_gl_t *, void *)
Definition: xine_gl.h:58
void(* set_native_window)(xine_gl_t *, void *)
Definition: xine_gl.h:46
void(* dispose)(xine_gl_t **)
Definition: xine_gl.h:48
Definition: xine_internal.h:80
Definition: sorted_array.c:34
const char * name
Definition: xine.c:1569
xine_gl_t * _x_load_gl(xine_t *xine, unsigned visual_type, const void *visual, unsigned flags)
Definition: xine_gl.c:56
static int xine_gl_extensions_test(xine_gl_extensions_t *e, const char *name)
Definition: xine_gl.h:125
static void xine_gl_extensions_load(xine_gl_extensions_t *e, const char *list)
Definition: xine_gl.h:94
static void xine_gl_extensions_unload(xine_gl_extensions_t *e)
Definition: xine_gl.h:87
static int _x_gl_has_extension(const char *extensions, const char *const ext)
Definition: xine_gl.h:64
NULL
Definition: xine_plugin.c:78