opengl: expose orientation instead of vflip

Like in the D3D11 implementation, any OpenGL implementation and
especially those coming from the user might ask a specific rendering
orientation to remove the need to rotate the image after it has been
done by the renderer.

In particular, the libvlc output callback allows any orientation to be
supplied by the user, but was currently ignored in release and was
asserting in debug because it didn't support that.

This commit changes the definition and usage of the opengl (offscreen)
providers to expose a format instead. It is now also exposed for
on-screen implementations also.
This commit is contained in:
Alexandre Janniaux 2023-06-13 08:05:18 +02:00 committed by Steve Lhomme
parent 4b16a94d39
commit a64afdae2c
5 changed files with 11 additions and 7 deletions

View File

@ -24,6 +24,8 @@
#ifndef VLC_GL_H
#define VLC_GL_H 1
#include <vlc_es.h>
# ifdef __cplusplus
extern "C" {
# endif
@ -108,12 +110,13 @@ struct vlc_gl_t
struct { /* off-screen */
vlc_fourcc_t offscreen_chroma_out;
struct vlc_video_context *offscreen_vctx_out;
/* Flag to indicate if the OpenGL implementation produces upside-down
* pictures */
bool offscreen_vflip;
};
};
/* Orientation that signals how the content should be generated by
* the client of the OpenGL provider. */
video_orientation_t orientation;
/* Defined by the core for libvlc_opengl API loading. */
enum vlc_gl_api_type api_type;

View File

@ -437,7 +437,7 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned height,
.close = Close,
};
gl->ops = &gl_ops;
gl->offscreen_vflip = true;
gl->orientation = ORIENT_VFLIPPED;
eglMakeCurrent(sys->display, sys->surface, sys->surface,
sys->context);

View File

@ -248,7 +248,7 @@ static int Open( vlc_object_t *obj )
}
free(glfilters_config);
if (sys->gl->offscreen_vflip)
if (sys->gl->orientation == ORIENT_VFLIPPED)
{
/* OpenGL renders upside-down, add a filter to get the pixels in the
* normal orientation */

View File

@ -355,7 +355,7 @@ static void FreeCVBuffer(picture_t *picture)
.close = Close,
};
gl->ops = &gl_ops;
gl->offscreen_vflip = true;
gl->orientation = ORIENT_VFLIPPED;
gl->offscreen_vctx_out = _vctx_out;
gl->offscreen_chroma_out = VLC_CODEC_CVPX_BGRA;

View File

@ -89,6 +89,7 @@ vlc_gl_t *vlc_gl_Create(const struct vout_display_cfg *restrict cfg,
vlc_gl_t *gl = &glpriv->gl;
gl->api_type = api_type;
gl->orientation = ORIENT_NORMAL;
gl->surface = wnd;
gl->device = NULL;
@ -144,9 +145,9 @@ vlc_gl_t *vlc_gl_CreateOffscreen(vlc_object_t *parent,
vlc_gl_t *gl = &glpriv->gl;
gl->api_type = api_type;
gl->orientation = ORIENT_NORMAL;
gl->offscreen_chroma_out = VLC_CODEC_UNKNOWN;
gl->offscreen_vflip = false;
gl->offscreen_vctx_out = NULL;
gl->surface = NULL;