Commit 5b4e4f28 authored by Thomas Guillem's avatar Thomas Guillem

Revert "vlc_opengl: refactor vlc_gl_t creation"

And use vlc_object_create() instead of the newly reverted vlc_gl_Create().

This reverts commit 79b21876.
refs #17795
parent 377d831f
......@@ -58,27 +58,7 @@ enum {
VLC_OPENGL_ES2,
};
/**
* Create a VLC OpenGL object
*
* @note The allocated resource, if any, shall be released
* with a call to \ref vlc_gl_Destroy.
* @return a created object on success, NULL on failure.
**/
VLC_API vlc_gl_t *vlc_gl_Create(vlc_object_t* parent);
/**
* Creates a VLC OpenGL object with associated surface and module
*
* @note In most cases, you should vlc_gl_MakeCurrent() afterward.
*
* @param wnd window to use as OpenGL surface
* @param flags OpenGL context type
* @param name module name (or NULL for auto)
* @return a new context, or NULL on failure
*/
VLC_API vlc_gl_t *vlc_gl_ModuleCreate(struct vout_window_t *wnd, unsigned flags,
const char *name) VLC_USED;
VLC_API vlc_gl_t *vlc_gl_Create(struct vout_window_t *, unsigned, const char *) VLC_USED;
VLC_API void vlc_gl_Destroy(vlc_gl_t *);
static inline int vlc_gl_MakeCurrent(vlc_gl_t *gl)
......
......@@ -171,7 +171,7 @@ static int Open (vlc_object_t *p_this)
msg_Warn(vd, "we might not have an OpenGL context yet");
/* Initialize common OpenGL video display */
sys->gl = vlc_gl_Create(vd);
sys->gl = vlc_object_create(vd, sizeof(*sys->gl));
if (unlikely(!sys->gl))
goto bailout;
sys->gl->makeCurrent = OpenglLock;
......
......@@ -254,7 +254,7 @@ static int Open (vlc_object_t *this)
}
/* Initialize common OpenGL video display */
sys->gl = vlc_gl_Create(this);
sys->gl = vlc_object_create(this, sizeof(*sys->gl));
if( unlikely( !sys->gl ) )
goto error;
......
......@@ -103,7 +103,7 @@ static int Open (vlc_object_t *obj)
goto error;
}
sys->gl = vlc_gl_ModuleCreate (surface, API, "$" MODULE_VARNAME);
sys->gl = vlc_gl_Create (surface, API, "$" MODULE_VARNAME);
if (sys->gl == NULL)
goto error;
......
......@@ -215,7 +215,7 @@ static int Open(vlc_object_t *object)
#endif
/* */
sys->gl = vlc_gl_Create(object);
sys->gl = vlc_object_create(object, sizeof(*sys->gl));
if (unlikely(!sys->gl))
goto error;
......
......@@ -691,7 +691,6 @@ vlc_fifo_GetCount
vlc_fifo_GetBytes
vlc_gl_Create
vlc_gl_Destroy
vlc_gl_ModuleCreate
vlc_gl_surface_Create
vlc_gl_surface_CheckSize
vlc_gl_surface_Destroy
......
......@@ -29,43 +29,47 @@
#include <vlc_opengl.h>
#include "libvlc.h"
#include <vlc_modules.h>
#include <vlc_vout_window.h>
vlc_gl_t *vlc_gl_Create(vlc_object_t* parent)
{
return vlc_custom_create(parent, sizeof(vlc_gl_t), "gl");
}
vlc_gl_t *vlc_gl_ModuleCreate(struct vout_window_t *wnd, unsigned flags,
const char *module_name)
#undef vlc_gl_Create
/**
* Creates an OpenGL context (and its underlying surface).
*
* @note In most cases, you should vlc_gl_MakeCurrent() afterward.
*
* @param wnd window to use as OpenGL surface
* @param flags OpenGL context type
* @param name module name (or NULL for auto)
* @return a new context, or NULL on failure
*/
vlc_gl_t *vlc_gl_Create(struct vout_window_t *wnd, unsigned flags,
const char *name)
{
const char *module_type;
vlc_object_t *parent = (vlc_object_t *)wnd;
vlc_gl_t *gl;
const char *type;
switch (flags)
switch (flags /*& VLC_OPENGL_API_MASK*/)
{
case VLC_OPENGL:
module_type = "opengl";
type = "opengl";
break;
case VLC_OPENGL_ES:
module_type = "opengl es";
type = "opengl es";
break;
case VLC_OPENGL_ES2:
module_type = "opengl es2";
type = "opengl es2";
break;
default:
return NULL;
}
vlc_gl_t *gl = vlc_gl_Create(VLC_OBJECT(wnd));
if( unlikely( !gl ) )
gl = vlc_custom_create(parent, sizeof (*gl), "gl");
if (unlikely(gl == NULL))
return NULL;
gl->surface = wnd;
gl->module = module_need(gl, module_type, module_name, true);
if (gl->module == NULL )
gl->module = module_need(gl, type, name, true);
if (gl->module == NULL)
{
vlc_object_release(gl);
return NULL;
......@@ -76,11 +80,12 @@ vlc_gl_t *vlc_gl_ModuleCreate(struct vout_window_t *wnd, unsigned flags,
void vlc_gl_Destroy(vlc_gl_t *gl)
{
if(gl->module)
module_unneed(gl, gl->module);
vlc_object_release(gl);
}
#include <vlc_vout_window.h>
typedef struct vlc_gl_surface
{
int width;
......@@ -125,7 +130,7 @@ vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *obj,
*wp = surface;
/* TODO: support ES? */
vlc_gl_t *gl = vlc_gl_ModuleCreate(surface, VLC_OPENGL, NULL);
vlc_gl_t *gl = vlc_gl_Create(surface, VLC_OPENGL, NULL);
if (gl == NULL) {
vout_window_Delete(surface);
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment