mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
eglglessink: Move DAR query & store to surface init
The DAR (display's pixel aspect ratio) should remain a constant at runtime so there's no point on repeatedly query and store this value. Doing it at surface setup should be enough. As an added bonus this change should make rendering a bit faster.
This commit is contained in:
parent
406630a294
commit
32861ab0a7
1 changed files with 35 additions and 36 deletions
|
@ -1538,7 +1538,6 @@ static gboolean
|
||||||
gst_eglglessink_update_surface_dimensions (GstEglGlesSink * eglglessink)
|
gst_eglglessink_update_surface_dimensions (GstEglGlesSink * eglglessink)
|
||||||
{
|
{
|
||||||
gint width, height;
|
gint width, height;
|
||||||
EGLint display_par;
|
|
||||||
|
|
||||||
/* Save surface dims */
|
/* Save surface dims */
|
||||||
eglQuerySurface (eglglessink->eglglesctx.display,
|
eglQuerySurface (eglglessink->eglglesctx.display,
|
||||||
|
@ -1546,41 +1545,6 @@ gst_eglglessink_update_surface_dimensions (GstEglGlesSink * eglglessink)
|
||||||
eglQuerySurface (eglglessink->eglglesctx.display,
|
eglQuerySurface (eglglessink->eglglesctx.display,
|
||||||
eglglessink->eglglesctx.surface, EGL_HEIGHT, &height);
|
eglglessink->eglglesctx.surface, EGL_HEIGHT, &height);
|
||||||
|
|
||||||
/* Save display's pixel aspect ratio
|
|
||||||
*
|
|
||||||
* DAR is reported as w/h * EGL_DISPLAY_SCALING wich is
|
|
||||||
* a constant with value 10000. This attribute is only
|
|
||||||
* supported if the EGL version is >= 1.2
|
|
||||||
* XXX: Setup this as a property.
|
|
||||||
* XXX: Move this initialization out to init_egl_surface()
|
|
||||||
* or some other one time check. Right now it's being called once
|
|
||||||
* per frame.
|
|
||||||
*/
|
|
||||||
if (eglglessink->eglglesctx.egl_major == 1 &&
|
|
||||||
eglglessink->eglglesctx.egl_minor < 2) {
|
|
||||||
GST_DEBUG_OBJECT (eglglessink, "Can't query PAR. Using default: %dx%d",
|
|
||||||
EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING);
|
|
||||||
eglglessink->eglglesctx.pixel_aspect_ratio = EGL_DISPLAY_SCALING;
|
|
||||||
} else {
|
|
||||||
eglQuerySurface (eglglessink->eglglesctx.display,
|
|
||||||
eglglessink->eglglesctx.surface, EGL_PIXEL_ASPECT_RATIO,
|
|
||||||
&display_par);
|
|
||||||
/* Fix for outbound DAR reporting on some implementations not
|
|
||||||
* honoring the 'should return w/h * EGL_DISPLAY_SCALING' spec
|
|
||||||
* requirement
|
|
||||||
*/
|
|
||||||
if (display_par == EGL_UNKNOWN || display_par < EGL_SANE_DAR_MIN ||
|
|
||||||
display_par > EGL_SANE_DAR_MAX) {
|
|
||||||
GST_DEBUG_OBJECT (eglglessink, "Nonsensical PAR value returned: %d. "
|
|
||||||
"Bad EGL implementation? "
|
|
||||||
"Will use default: %d/%d", eglglessink->eglglesctx.pixel_aspect_ratio,
|
|
||||||
EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING);
|
|
||||||
eglglessink->eglglesctx.pixel_aspect_ratio = EGL_DISPLAY_SCALING;
|
|
||||||
} else {
|
|
||||||
eglglessink->eglglesctx.pixel_aspect_ratio = display_par;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (width != eglglessink->eglglesctx.surface_width ||
|
if (width != eglglessink->eglglesctx.surface_width ||
|
||||||
height != eglglessink->eglglesctx.surface_height) {
|
height != eglglessink->eglglesctx.surface_height) {
|
||||||
eglglessink->eglglesctx.surface_width = width;
|
eglglessink->eglglesctx.surface_width = width;
|
||||||
|
@ -1635,6 +1599,7 @@ gst_eglglessink_init_egl_surface (GstEglGlesSink * eglglessink)
|
||||||
GLint test;
|
GLint test;
|
||||||
GLboolean ret;
|
GLboolean ret;
|
||||||
GLchar *info_log;
|
GLchar *info_log;
|
||||||
|
EGLint display_par;
|
||||||
const gchar *texnames[3] = { NULL, };
|
const gchar *texnames[3] = { NULL, };
|
||||||
gchar *tmp_prog = NULL;
|
gchar *tmp_prog = NULL;
|
||||||
|
|
||||||
|
@ -1654,6 +1619,40 @@ gst_eglglessink_init_egl_surface (GstEglGlesSink * eglglessink)
|
||||||
if (!gst_eglglessink_context_make_current (eglglessink, TRUE))
|
if (!gst_eglglessink_context_make_current (eglglessink, TRUE))
|
||||||
goto HANDLE_EGL_ERROR_LOCKED;
|
goto HANDLE_EGL_ERROR_LOCKED;
|
||||||
|
|
||||||
|
/* Save display's pixel aspect ratio
|
||||||
|
*
|
||||||
|
* DAR is reported as w/h * EGL_DISPLAY_SCALING wich is
|
||||||
|
* a constant with value 10000. This attribute is only
|
||||||
|
* supported if the EGL version is >= 1.2
|
||||||
|
* XXX: Setup this as a property.
|
||||||
|
* or some other one time check. Right now it's being called once
|
||||||
|
* per frame.
|
||||||
|
*/
|
||||||
|
if (eglglessink->eglglesctx.egl_major == 1 &&
|
||||||
|
eglglessink->eglglesctx.egl_minor < 2) {
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Can't query PAR. Using default: %dx%d",
|
||||||
|
EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING);
|
||||||
|
eglglessink->eglglesctx.pixel_aspect_ratio = EGL_DISPLAY_SCALING;
|
||||||
|
} else {
|
||||||
|
eglQuerySurface (eglglessink->eglglesctx.display,
|
||||||
|
eglglessink->eglglesctx.surface, EGL_PIXEL_ASPECT_RATIO,
|
||||||
|
&display_par);
|
||||||
|
/* Fix for outbound DAR reporting on some implementations not
|
||||||
|
* honoring the 'should return w/h * EGL_DISPLAY_SCALING' spec
|
||||||
|
* requirement
|
||||||
|
*/
|
||||||
|
if (display_par == EGL_UNKNOWN || display_par < EGL_SANE_DAR_MIN ||
|
||||||
|
display_par > EGL_SANE_DAR_MAX) {
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Nonsensical PAR value returned: %d. "
|
||||||
|
"Bad EGL implementation? "
|
||||||
|
"Will use default: %d/%d", eglglessink->eglglesctx.pixel_aspect_ratio,
|
||||||
|
EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING);
|
||||||
|
eglglessink->eglglesctx.pixel_aspect_ratio = EGL_DISPLAY_SCALING;
|
||||||
|
} else {
|
||||||
|
eglglessink->eglglesctx.pixel_aspect_ratio = display_par;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Save surface dims */
|
/* Save surface dims */
|
||||||
gst_eglglessink_update_surface_dimensions (eglglessink);
|
gst_eglglessink_update_surface_dimensions (eglglessink);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue