xine-lib: xine-lib-1.2.12/src/video_out/opengl/xine_gl.h Source File

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
36 typedef struct xine_gl xine_gl_t;
37
38 struct xine_gl {
39 int (*make_current) (xine_gl_t *);
40 void (*release_current) (xine_gl_t *);
41 void (*swap_buffers) (xine_gl_t *);
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
61 xine_gl_t *_x_load_gl(xine_t *xine, unsigned visual_type, const void *visual, unsigned flags);
62
63
64 static 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
82 typedef struct {
83 xine_sarray_t *list;
84 unsigned char *buf;
85} xine_gl_extensions_t;
86
87 static inline void xine_gl_extensions_unload (xine_gl_extensions_t *e) {
88 xine_sarray_delete (e->list);
89 free (e->buf);
90 e->list = NULL;
91 e->buf = NULL;
92}
93
94 static 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) {
108 xine_gl_extensions_unload (e);
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
125 static 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_ */
height
unsigned int height
Definition: gfontrle.c:5
width
unsigned int width
Definition: gfontrle.c:4
xine_sarray_binary_search
int xine_sarray_binary_search(xine_sarray_t *sarray, void *key)
Definition: sorted_array.c:101
xine_sarray_delete
void xine_sarray_delete(xine_sarray_t *sarray)
Definition: sorted_array.c:132
xine_sarray_add
int xine_sarray_add(xine_sarray_t *sarray, void *value)
Definition: sorted_array.c:278
xine_sarray_new
xine_sarray_t * xine_sarray_new(size_t initial_size, xine_sarray_comparator_t comparator)
Definition: sorted_array.c:111
sorted_array.h
xine_sarray_comparator_t
int(* xine_sarray_comparator_t)(void *, void *)
Definition: sorted_array.h:67
xine_gl_extensions_t
Definition: xine_gl.h:82
xine_gl_extensions_t::buf
unsigned char * buf
Definition: xine_gl.h:84
xine_gl_extensions_t::list
xine_sarray_t * list
Definition: xine_gl.h:83
xine_gl
Definition: xine_gl.h:38
xine_gl::resize
void(* resize)(xine_gl_t *, int width, int height)
Definition: xine_gl.h:44
xine_gl::make_current
int(* make_current)(xine_gl_t *)
Definition: xine_gl.h:39
xine_gl::swap_buffers
void(* swap_buffers)(xine_gl_t *)
Definition: xine_gl.h:41
xine_gl::release_current
void(* release_current)(xine_gl_t *)
Definition: xine_gl.h:40
xine_gl::eglDestroyImageKHR
int(* eglDestroyImageKHR)(xine_gl_t *, void *)
Definition: xine_gl.h:58
xine_gl::set_native_window
void(* set_native_window)(xine_gl_t *, void *)
Definition: xine_gl.h:46
xine_gl::dispose
void(* dispose)(xine_gl_t **)
Definition: xine_gl.h:48
xine_s
Definition: xine_internal.h:80
xine_sarray_s
Definition: sorted_array.c:34
name
const char * name
Definition: xine.c:1569
xine.h
_x_load_gl
xine_gl_t * _x_load_gl(xine_t *xine, unsigned visual_type, const void *visual, unsigned flags)
Definition: xine_gl.c:56
xine_gl_extensions_test
static int xine_gl_extensions_test(xine_gl_extensions_t *e, const char *name)
Definition: xine_gl.h:125
xine_gl_extensions_load
static void xine_gl_extensions_load(xine_gl_extensions_t *e, const char *list)
Definition: xine_gl.h:94
xine_gl_extensions_unload
static void xine_gl_extensions_unload(xine_gl_extensions_t *e)
Definition: xine_gl.h:87
_x_gl_has_extension
static int _x_gl_has_extension(const char *extensions, const char *const ext)
Definition: xine_gl.h:64
NULL
NULL
Definition: xine_plugin.c:78