Commit de2f3f51 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Replace vout_opengl_t with vlc_gl_t

This is purely a syntactical change to share the opengl.c code.
This commit does not actually make use of the vlc_gl_Create().
parent 97a961bd
......@@ -172,7 +172,7 @@ enum {
VOUT_DISPLAY_CHANGE_SOURCE_CROP, /* const video_format_t *p_source */
/* Ask an opengl interface if available. */
VOUT_DISPLAY_GET_OPENGL, /* vout_opengl_t ** */
VOUT_DISPLAY_GET_OPENGL, /* vlc_gl_t ** */
};
/**
......
/*****************************************************************************
* vlc_vout_opengl.h: vout_opengl_t definitions
*****************************************************************************
* Copyright (C) 2009 Laurent Aimar
* $Id$
*
* Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_VOUT_OPENGL_H
#define VLC_VOUT_OPENGL_H 1
/**
* \file
* This file defines vout opengl structures and functions in vlc
*/
#include <vlc_common.h>
typedef struct vout_opengl_t vout_opengl_t;
struct vout_opengl_t {
/* */
int (*lock)(vout_opengl_t *);
void (*swap)(vout_opengl_t *);
void (*unlock)(vout_opengl_t *);
/* */
void *sys;
};
static inline int vout_opengl_Lock(vout_opengl_t *gl)
{
if (!gl->lock)
return VLC_SUCCESS;
return gl->lock(gl);
}
static inline void vout_opengl_Unlock(vout_opengl_t *gl)
{
if (gl->unlock)
gl->unlock(gl);
}
static inline void vout_opengl_Swap(vout_opengl_t *gl)
{
gl->swap(gl);
}
#endif /* VLC_VOUT_OPENGL_H */
......@@ -25,7 +25,6 @@
#define VLC_VOUT_WRAPPER_H 1
#include <vlc_vout_display.h>
#include <vlc_vout_opengl.h>
/* XXX DO NOT use it outside the vout module wrapper XXX */
......@@ -91,7 +90,9 @@ VLC_EXPORT(void, vout_SetDisplayZoom, (vout_display_t *, int num, int den));
VLC_EXPORT(void, vout_SetWindowState, (vout_display_t *, unsigned state));
VLC_EXPORT(void, vout_SetDisplayAspect, (vout_display_t *, unsigned dar_num, unsigned dar_den));
VLC_EXPORT(void, vout_SetDisplayCrop, (vout_display_t *, unsigned crop_num, unsigned crop_den, unsigned left, unsigned top, int right, int bottom));
VLC_EXPORT(vout_opengl_t *, vout_GetDisplayOpengl, (vout_display_t *));
struct vlc_gl_t;
VLC_EXPORT(struct vlc_gl_t *, vout_GetDisplayOpengl, (vout_display_t *));
#endif /* VLC_VOUT_WRAPPER_H */
......@@ -31,7 +31,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_vout_display.h>
#include <vlc_vout_opengl.h>
#include <vlc_opengl.h>
#include "opengl.h"
#ifdef __unix__
# include <vlc_xlib.h>
......@@ -73,7 +73,7 @@ struct vout_display_sys_t
EGLDisplay display;
EGLSurface surface;
vout_opengl_t gl;
vlc_gl_t gl;
vout_display_opengl_t vgl;
picture_pool_t *pool;
......@@ -86,7 +86,7 @@ static void PictureRender (vout_display_t *, picture_t *, subpicture_t *);
static void PictureDisplay (vout_display_t *, picture_t *, subpicture_t *);
static int Control (vout_display_t *, int, va_list);
/* OpenGL callbacks */
static void SwapBuffers (vout_opengl_t *gl);
static void SwapBuffers (vlc_gl_t *gl);
static bool CheckAPI (EGLDisplay dpy, const char *api)
{
......@@ -297,7 +297,7 @@ static void Close (vlc_object_t *obj)
free (sys);
}
static void SwapBuffers (vout_opengl_t *gl)
static void SwapBuffers (vlc_gl_t *gl)
{
vout_display_sys_t *sys = gl->sys;
......@@ -400,7 +400,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
case VOUT_DISPLAY_GET_OPENGL:
{
vout_opengl_t **gl = va_arg (ap, vout_opengl_t **);
vlc_gl_t **gl = va_arg (ap, vlc_gl_t **);
*gl = &sys->gl;
return VLC_SUCCESS;
......
......@@ -37,7 +37,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_vout_display.h>
#include <vlc_vout_opengl.h>
#include <vlc_opengl.h>
#define USE_OPENGL_ES 1
......@@ -54,8 +54,8 @@ static void PictureRender(vout_display_t *vd, picture_t *pic, subpicture_t *subp
static void PictureDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
static int Control (vout_display_t *vd, int query, va_list ap);
static int OpenglClean(vout_opengl_t *gl);
static void OpenglSwap(vout_opengl_t *gl);
static int OpenglClean(vlc_gl_t *gl);
static void OpenglSwap(vlc_gl_t *gl);
/**
* Module declaration
......@@ -93,7 +93,7 @@ struct vout_display_sys_t
VLCOpenGLESVideoView *glView;
UIView * container;
vout_opengl_t gl;
vlc_gl_t gl;
vout_display_opengl_t vgl;
picture_pool_t *pool;
......@@ -254,7 +254,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
case VOUT_DISPLAY_GET_OPENGL:
{
vout_opengl_t **gl = va_arg (ap, vout_opengl_t **);
vlc_gl_t **gl = va_arg (ap, vlc_gl_t **);
*gl = &sys->gl;
return VLC_SUCCESS;
}
......@@ -271,13 +271,13 @@ static int Control (vout_display_t *vd, int query, va_list ap)
* vout opengl callbacks
*****************************************************************************/
static int OpenglClean(vout_opengl_t *gl) {
static int OpenglClean(vlc_gl_t *gl) {
vout_display_sys_t *sys = gl->sys;
[sys->glView cleanFramebuffer];
return 0;
}
static void OpenglSwap(vout_opengl_t *gl)
static void OpenglSwap(vlc_gl_t *gl)
{
vout_display_sys_t *sys = gl->sys;
EAGLContext *context = [sys->glView context];
......
......@@ -42,7 +42,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_vout_display.h>
#include <vlc_vout_opengl.h>
#include <vlc_opengl.h>
#include "opengl.h"
/**
......@@ -56,9 +56,9 @@ static void PictureRender(vout_display_t *vd, picture_t *pic, subpicture_t *subp
static void PictureDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
static int Control (vout_display_t *vd, int query, va_list ap);
static int OpenglLock(vout_opengl_t *gl);
static void OpenglUnlock(vout_opengl_t *gl);
static void OpenglSwap(vout_opengl_t *gl);
static int OpenglLock(vlc_gl_t *gl);
static void OpenglUnlock(vlc_gl_t *gl);
static void OpenglSwap(vlc_gl_t *gl);
/**
* Module declaration
......@@ -99,7 +99,7 @@ struct vout_display_sys_t
id<VLCOpenGLVideoViewEmbedding> container;
vout_window_t *embed;
vout_opengl_t gl;
vlc_gl_t gl;
vout_display_opengl_t vgl;
picture_pool_t *pool;
......@@ -303,7 +303,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
case VOUT_DISPLAY_GET_OPENGL:
{
vout_opengl_t **gl = va_arg (ap, vout_opengl_t **);
vlc_gl_t **gl = va_arg (ap, vlc_gl_t **);
*gl = &sys->gl;
return VLC_SUCCESS;
}
......@@ -319,7 +319,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
/*****************************************************************************
* vout opengl callbacks
*****************************************************************************/
static int OpenglLock(vout_opengl_t *gl)
static int OpenglLock(vlc_gl_t *gl)
{
vout_display_sys_t *sys = (vout_display_sys_t *)gl->sys;
NSOpenGLContext *context = [sys->glView openGLContext];
......@@ -332,13 +332,13 @@ static int OpenglLock(vout_opengl_t *gl)
return 1;
}
static void OpenglUnlock(vout_opengl_t *gl)
static void OpenglUnlock(vlc_gl_t *gl)
{
vout_display_sys_t *sys = (vout_display_sys_t *)gl->sys;
CGLUnlockContext([[sys->glView openGLContext] CGLContextObj]);
}
static void OpenglSwap(vout_opengl_t *gl)
static void OpenglSwap(vlc_gl_t *gl)
{
vout_display_sys_t *sys = (vout_display_sys_t *)gl->sys;
[[sys->glView openGLContext] flushBuffer];
......
......@@ -151,7 +151,7 @@ struct vout_display_sys_t
#ifdef MODULE_NAME_IS_glwin32
HDC hGLDC;
HGLRC hGLRC;
vout_opengl_t gl;
vlc_gl_t gl;
vout_display_opengl_t vgl;
#endif
......
......@@ -67,7 +67,7 @@ static void Display(vout_display_t *, picture_t *, subpicture_t *);
static int Control(vout_display_t *, int, va_list);
static void Manage (vout_display_t *);
static void Swap (vout_opengl_t *);
static void Swap (vlc_gl_t *);
/**
* It creates an OpenGL vout display.
......@@ -199,7 +199,7 @@ static int Control(vout_display_t *vd, int query, va_list args)
{
switch (query) {
case VOUT_DISPLAY_GET_OPENGL: {
vout_opengl_t **gl = va_arg(args, vout_opengl_t **);
vlc_gl_t **gl = va_arg(args, vlc_gl_t **);
*gl = &vd->sys->gl;
CommonDisplay(vd);
......@@ -221,7 +221,7 @@ static void Manage (vout_display_t *vd)
glViewport(0, 0, width, height);
}
static void Swap(vout_opengl_t *gl)
static void Swap(vlc_gl_t *gl)
{
vout_display_t *vd = gl->sys;
......
......@@ -27,7 +27,7 @@
#include <vlc_common.h>
#include <vlc_picture_pool.h>
#include <vlc_vout_opengl.h>
#include <vlc_opengl.h>
#include "opengl.h"
// Define USE_OPENGL_ES to the GL ES Version you want to select
......@@ -102,7 +102,7 @@ static inline int GetAlignedSize(unsigned size)
int vout_display_opengl_Init(vout_display_opengl_t *vgl,
video_format_t *fmt,
vout_opengl_t *gl)
vlc_gl_t *gl)
{
vgl->gl = gl;
......@@ -171,14 +171,14 @@ int vout_display_opengl_Init(vout_display_opengl_t *vgl,
#endif
#if defined(__APPLE__) && USE_OPENGL_ES == 1
if (!vout_opengl_Lock(vgl->gl)) {
if (!vlc_gl_Lock(vgl->gl)) {
const char* extensions = (char*) glGetString(GL_EXTENSIONS);
if (extensions) {
bool npot = strstr(extensions, "GL_APPLE_texture_2D_limited_npot") != 0;
if (npot)
supports_npot = true;
}
vout_opengl_Unlock(vgl->gl);
vlc_gl_Unlock(vgl->gl);
}
#endif
......@@ -195,7 +195,7 @@ int vout_display_opengl_Init(vout_display_opengl_t *vgl,
/* */
if (!vout_opengl_Lock(vgl->gl)) {
if (!vlc_gl_Lock(vgl->gl)) {
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
......@@ -204,7 +204,7 @@ int vout_display_opengl_Init(vout_display_opengl_t *vgl,
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
vout_opengl_Unlock(vgl->gl);
vlc_gl_Unlock(vgl->gl);
}
return VLC_SUCCESS;
}
......@@ -212,13 +212,13 @@ int vout_display_opengl_Init(vout_display_opengl_t *vgl,
void vout_display_opengl_Clean(vout_display_opengl_t *vgl)
{
/* */
if (!vout_opengl_Lock(vgl->gl)) {
if (!vlc_gl_Lock(vgl->gl)) {
glFinish();
glFlush();
glDeleteTextures(VLCGL_TEXTURE_COUNT, vgl->texture);
vout_opengl_Unlock(vgl->gl);
vlc_gl_Unlock(vgl->gl);
}
if (vgl->pool) {
picture_pool_Delete(vgl->pool);
......@@ -229,7 +229,7 @@ void vout_display_opengl_Clean(vout_display_opengl_t *vgl)
int vout_display_opengl_ResetTextures(vout_display_opengl_t *vgl)
{
if (vout_opengl_Lock(vgl->gl))
if (vlc_gl_Lock(vgl->gl))
return VLC_EGENERIC;
glDeleteTextures(VLCGL_TEXTURE_COUNT, vgl->texture);
......@@ -274,7 +274,7 @@ int vout_display_opengl_ResetTextures(vout_display_opengl_t *vgl)
}
}
vout_opengl_Unlock(vgl->gl);
vlc_gl_Unlock(vgl->gl);
return VLC_SUCCESS;
}
......@@ -297,13 +297,13 @@ static int PictureLock(picture_t *picture)
return VLC_SUCCESS;
vout_display_opengl_t *vgl = picture->p_sys->vgl;
if (!vout_opengl_Lock(vgl->gl)) {
if (!vlc_gl_Lock(vgl->gl)) {
glBindTexture(VLCGL_TARGET, get_texture(picture));
glTexSubImage2D(VLCGL_TARGET, 0, 0, 0,
vgl->fmt.i_width, vgl->fmt.i_height,
VLCGL_FORMAT, VLCGL_TYPE, picture->p[0].p_pixels);
vout_opengl_Unlock(vgl->gl);
vlc_gl_Unlock(vgl->gl);
}
return VLC_SUCCESS;
}
......@@ -394,7 +394,7 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
lock(/unlock) managed picture pool.
*/
if (vout_opengl_Lock(vgl->gl))
if (vlc_gl_Lock(vgl->gl))
return VLC_EGENERIC;
#ifdef MACOS_OPENGL
......@@ -407,14 +407,14 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
VLCGL_FORMAT, VLCGL_TYPE, picture->p[0].p_pixels);
#endif
vout_opengl_Unlock(vgl->gl);
vlc_gl_Unlock(vgl->gl);
return VLC_SUCCESS;
}
int vout_display_opengl_Display(vout_display_opengl_t *vgl,
const video_format_t *source)
{
if (vout_opengl_Lock(vgl->gl))
if (vlc_gl_Lock(vgl->gl))
return VLC_EGENERIC;
/* glTexCoord works differently with GL_TEXTURE_2D and
......@@ -475,9 +475,9 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
glDisable(VLCGL_TARGET);
vout_opengl_Swap(vgl->gl);
vlc_gl_Swap(vgl->gl);
vout_opengl_Unlock(vgl->gl);
vlc_gl_Unlock(vgl->gl);
return VLC_SUCCESS;
}
......@@ -27,7 +27,7 @@
#include <vlc_common.h>
#include <vlc_picture_pool.h>
#include <vlc_vout_opengl.h>
#include <vlc_opengl.h>
// Define USE_OPENGL_ES to the GL ES Version you want to select
#ifndef USE_OPENGL_ES
......@@ -50,7 +50,7 @@
#endif
typedef struct {
vout_opengl_t *gl;
vlc_gl_t *gl;
video_format_t fmt;
......@@ -65,7 +65,7 @@ typedef struct {
} vout_display_opengl_t;
int vout_display_opengl_Init(vout_display_opengl_t *vgl,
video_format_t *fmt, vout_opengl_t *gl);
video_format_t *fmt, vlc_gl_t *gl);
void vout_display_opengl_Clean(vout_display_opengl_t *vgl);
int vout_display_opengl_ResetTextures(vout_display_opengl_t *vgl);
......
......@@ -36,7 +36,7 @@
#include <vlc_plugin.h>
#include <vlc_xlib.h>
#include <vlc_vout_display.h>
#include <vlc_vout_opengl.h>
#include <vlc_opengl.h>
#include "../opengl.h"
#include "xcb_vlc.h"
......@@ -70,7 +70,7 @@ struct vout_display_sys_t
bool v1_3; /* whether GLX >= 1.3 is available */
GLXContext ctx;
vout_opengl_t gl;
vlc_gl_t gl;
vout_display_opengl_t vgl;
picture_pool_t *pool; /* picture pool */
};
......@@ -81,7 +81,7 @@ static void PictureDisplay (vout_display_t *, picture_t *, subpicture_t *);
static int Control (vout_display_t *, int, va_list);
static void Manage (vout_display_t *);
static void SwapBuffers (vout_opengl_t *gl);
static void SwapBuffers (vlc_gl_t *gl);
static vout_window_t *MakeWindow (vout_display_t *vd)
{
......@@ -436,7 +436,7 @@ static void Close (vlc_object_t *obj)
free (sys);
}
static void SwapBuffers (vout_opengl_t *gl)
static void SwapBuffers (vlc_gl_t *gl)
{
vout_display_sys_t *sys = gl->sys;
......@@ -553,7 +553,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
case VOUT_DISPLAY_GET_OPENGL:
{
vout_opengl_t **gl = va_arg (ap, vout_opengl_t **);
vlc_gl_t **gl = va_arg (ap, vlc_gl_t **);
*gl = &sys->gl;
return VLC_SUCCESS;
}
......
......@@ -285,7 +285,7 @@ static void *Thread( void *p_data )
filter_sys_t *p_sys = p_filter->p_sys;
int cancel = vlc_savecancel();
video_format_t fmt;
vout_opengl_t *gl;
vlc_gl_t *gl;
int i_last_width = 0;
int i_last_height = 0;
locale_t loc;
......@@ -442,10 +442,10 @@ static void *Thread( void *p_data )
/* */
mwait( i_deadline );
if( !vout_opengl_Lock(gl) )
if( !vlc_gl_Lock(gl) )
{
vout_opengl_Swap( gl );
vout_opengl_Unlock( gl );
vlc_gl_Swap( gl );
vlc_gl_Unlock( gl );
}
}
abort();
......
......@@ -109,7 +109,6 @@ pluginsinclude_HEADERS = \
../include/vlc_video_splitter.h \
../include/vlc_vout.h \
../include/vlc_vout_display.h \
../include/vlc_vout_opengl.h \
../include/vlc_vout_osd.h \
../include/vlc_vout_window.h \
../include/vlc_xml.h \
......
......@@ -1207,9 +1207,10 @@ void vout_SetDisplayCrop(vout_display_t *vd,
osys->ch_crop = true;
}
}
vout_opengl_t *vout_GetDisplayOpengl(vout_display_t *vd)
struct vlc_gl_t *vout_GetDisplayOpengl(vout_display_t *vd)
{
vout_opengl_t *gl;
struct vlc_gl_t *gl;
if (vout_display_Control(vd, VOUT_DISPLAY_GET_OPENGL, &gl))
return NULL;
return gl;
......
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