1 /*
2 * Copyright (C) 2018-2019 the xine project
3 * Copyright (C) 2018-2019 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.c, Interface between OpenGL and native windowing system
22 *
23 */
24
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 #include "xine_gl.h"
30 #include "xine_gl_plugin.h"
31
32 #include <stddef.h>
33
34 #include <xine/xine_internal.h>
35
36 #define PLUGIN(_gl) xine_container_of(_gl, xine_gl_plugin_t, gl)
37
38 /* technically, we can't unload dynamic module from the module itself.
39 * it would work now (nothing is unloaded), but there may be problems in
40 * the future if plugin loader unloads the library in _x_free_module().
41 */
default_gl_dispose(xine_gl_t ** pgl)42 static void default_gl_dispose(xine_gl_t **pgl)
43 {
44 if (*pgl) {
45 xine_gl_plugin_t *plugin = PLUGIN(*pgl);
46 xine_module_t *module = &plugin->module;
47 *pgl = NULL;
48 _x_free_module(plugin->xine, &module);
49 }
50 }
51
52 /*
53 * loader wrapper
54 */
55
_x_load_gl(xine_t * xine,unsigned visual_type,const void * visual,unsigned flags)56 xine_gl_t *_x_load_gl(xine_t *xine, unsigned visual_type, const void *visual, unsigned flags)
57 {
58 const gl_plugin_params_t params = {
59 .xine = xine,
60 .visual_type = visual_type,
61 .visual = visual,
62 .flags = flags,
63 };
64 xine_gl_plugin_t *p;
65
66 p = (xine_gl_plugin_t*)_x_find_module(xine, GL_PLUGIN_TYPE, NULL, visual_type, ¶ms);
67 if (p) {
68 p->gl.dispose = default_gl_dispose;
69 return &p->gl;
70 }
71 return NULL;
72 }
73
74
75