Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
gl: do not include GL headers in public gstgl headers
Except for gst/gl/gstglfuncs.h

It is up to the client app to include these headers.
It is coherent with the fact that gstreamer-gl.pc does not
require any egl.pc/gles.pc. I.e. it is the responsability
of the app to search these headers within its build setup.

For example gstreamer-vaapi includes explicitly EGL/egl.h
and search for it in its configure.ac.

For example with this patch, if an app includes the headers
  gst/gl/egl/gstglcontext_egl.h
  gst/gl/egl/gstgldisplay_egl.h
  gst/gl/egl/gstglmemoryegl.h
it will *no longer* automatically include EGL/egl.h and GLES2/gl2.h.
Which is good because the app might want to use the gstgl api only
without the need to bother about gl headers.

Also added a test: cd tests/check && make libs/gstglheaders.check

https://bugzilla.gnome.org/show_bug.cgi?id=784779
  • Loading branch information
Julien Isorce authored and tp-m committed Dec 9, 2017
1 parent 632015a commit 4952fdd
Show file tree
Hide file tree
Showing 74 changed files with 483 additions and 214 deletions.
2 changes: 2 additions & 0 deletions ext/gl/gltestsrc.c
Expand Up @@ -22,6 +22,8 @@
#include "config.h"
#endif

#include <gst/gl/gstglfuncs.h>

#include "gltestsrc.h"

#define MAX_ATTRIBUTES 4
Expand Down
6 changes: 3 additions & 3 deletions ext/gl/gstglcolorbalance.c
Expand Up @@ -38,12 +38,12 @@
#include "config.h"
#endif

#include <string.h>
#include <gst/gl/gstglfuncs.h>
#include <gst/math-compat.h>
#include <gst/video/colorbalance.h>

#include "gstglcolorbalance.h"
#include <string.h>

#include <gst/video/colorbalance.h>

GST_DEBUG_CATEGORY_STATIC (glcolorbalance_debug);
#define GST_CAT_DEFAULT glcolorbalance_debug
Expand Down
1 change: 0 additions & 1 deletion ext/gl/gstglcolorscale.c
Expand Up @@ -47,7 +47,6 @@

#include "gstglcolorscale.h"


#define GST_CAT_DEFAULT gst_gl_colorscale_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);

Expand Down
2 changes: 2 additions & 0 deletions ext/gl/gstgldeinterlace.c
Expand Up @@ -36,6 +36,8 @@
#include "config.h"
#endif

#include <gst/gl/gstglfuncs.h>

#include "gstgldeinterlace.h"

#define GST_CAT_DEFAULT gst_gl_deinterlace_debug
Expand Down
2 changes: 2 additions & 0 deletions ext/gl/gstgldifferencematte.c
Expand Up @@ -39,6 +39,8 @@
#include <stdlib.h>
#include <png.h>

#include <gst/gl/gstglfuncs.h>

#include "gstgldifferencematte.h"
#include "effects/gstgleffectssources.h"

Expand Down
1 change: 0 additions & 1 deletion ext/gl/gstgleffects.c
Expand Up @@ -36,7 +36,6 @@
#include "config.h"
#endif

#include <gst/gl/gstglconfig.h>
#include "gstgleffects.h"

#define GST_CAT_DEFAULT gst_gl_effects_debug
Expand Down
2 changes: 2 additions & 0 deletions ext/gl/gstgleffects.h
Expand Up @@ -22,6 +22,8 @@
#define __GST_GL_EFFECTS_H__

#include <gst/gl/gstglfilter.h>
#include <gst/gl/gstglfuncs.h>

#include "effects/gstgleffectssources.h"

G_BEGIN_DECLS
Expand Down
1 change: 1 addition & 0 deletions ext/gl/gstglfiltercube.h
Expand Up @@ -22,6 +22,7 @@
#define _GST_GL_FILTERCUBE_H_

#include <gst/gl/gstglfilter.h>
#include <gst/gl/gstglfuncs.h>

G_BEGIN_DECLS

Expand Down
3 changes: 3 additions & 0 deletions ext/gl/gstglfilterglass.c
Expand Up @@ -41,7 +41,10 @@
#endif

#include <math.h>
#include <gst/gl/gstglfuncs.h>

#include "gstglfilterglass.h"

#include "gstglutils.h"

#define GST_CAT_DEFAULT gst_gl_filter_glass_debug
Expand Down
2 changes: 1 addition & 1 deletion ext/gl/gstglfiltershader.c
Expand Up @@ -56,7 +56,7 @@
#include "config.h"
#endif

#include <gst/gst.h>
#include <gst/gl/gstglfuncs.h>

#include "gstglfiltershader.h"
#if HAVE_GRAPHENE
Expand Down
1 change: 1 addition & 0 deletions ext/gl/gstglimagesink.h
Expand Up @@ -28,6 +28,7 @@
#include <gst/video/video.h>

#include <gst/gl/gl.h>
#include <gst/gl/gstglfuncs.h>

G_BEGIN_DECLS

Expand Down
1 change: 1 addition & 0 deletions ext/gl/gstglmixer.h
Expand Up @@ -24,6 +24,7 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/gl/gl.h>
#include <gst/gl/gstglfuncs.h>
#include "gstglbasemixer.h"

G_BEGIN_DECLS
Expand Down
1 change: 1 addition & 0 deletions ext/gl/gstgloverlay.h
Expand Up @@ -22,6 +22,7 @@
#define _GST_GL_OVERLAY_H_

#include <gst/gl/gstglfilter.h>
#include <gst/gl/gstglfuncs.h>

G_BEGIN_DECLS

Expand Down
4 changes: 3 additions & 1 deletion ext/gl/gstgltestsrc.c
Expand Up @@ -42,9 +42,11 @@
#include "config.h"
#endif

#include <gst/gl/gstglfuncs.h>
#include <gst/gst-i18n-plugin.h>

#include "gstgltestsrc.h"
#include "gltestsrc.h"
#include <gst/gst-i18n-plugin.h>

#define USE_PEER_BUFFERALLOC
#define SUPPORTED_GL_APIS (GST_GL_API_OPENGL | GST_GL_API_OPENGL3 | GST_GL_API_GLES2)
Expand Down
3 changes: 2 additions & 1 deletion ext/gl/gstglutils.c
Expand Up @@ -22,7 +22,8 @@
#include "config.h"
#endif

#include <gst/gst.h>
#include <gst/gl/gstglfuncs.h>

#include "gstglutils.h"

struct _compile_shader
Expand Down
4 changes: 3 additions & 1 deletion ext/gl/gstglvideomixer.c
Expand Up @@ -43,10 +43,12 @@
#include "config.h"
#endif

#include <gst/video/gstvideoaffinetransformationmeta.h>
#include <gst/controller/gstproxycontrolbinding.h>
#include <gst/gl/gstglfuncs.h>
#include <gst/video/gstvideoaffinetransformationmeta.h>

#include "gstglvideomixer.h"

#include "gstglmixerbin.h"
#include "gstglutils.h"

Expand Down
1 change: 1 addition & 0 deletions ext/gl/gstglviewconvert.c
Expand Up @@ -47,6 +47,7 @@
#endif

#include <gst/base/gstbasetransform.h>

#include "gstglviewconvert.h"

#define GST_CAT_DEFAULT gst_gl_view_convert_element_debug
Expand Down
2 changes: 1 addition & 1 deletion ext/gl/gstglviewconvert.h
Expand Up @@ -22,7 +22,7 @@
#ifndef _GST_GL_VIEW_CONVERT_ELEMENT_H_
#define _GST_GL_VIEW_CONVERT_ELEMENT_H_

#include <gst/gl/gstglviewconvert.h>
#include <gst/gl/gstglfilter.h>

G_BEGIN_DECLS
#define GST_TYPE_GL_VIEW_CONVERT_ELEMENT (gst_gl_view_convert_element_get_type())
Expand Down
13 changes: 10 additions & 3 deletions gst-libs/gst/gl/egl/gsteglimage.c
Expand Up @@ -39,9 +39,16 @@
#endif

#include "gsteglimage.h"
#include <gst/gl/egl/gstgldisplay_egl.h>

#include <string.h>

#include <gst/gl/gstglfeature.h>
#include <gst/gl/gstglmemory.h>

#include "gst/gl/egl/gstegl.h"
#include "gst/gl/egl/gstglcontext_egl.h"
#include "gst/gl/egl/gstgldisplay_egl.h"

#if GST_GL_HAVE_DMABUF
#include <gst/allocators/gstdmabuf.h>
#include <libdrm/drm_fourcc.h>
Expand Down Expand Up @@ -107,7 +114,7 @@ gst_egl_image_ensure_debug_category (void)
*
* Returns: the #EGLImageKHR of @image
*/
EGLImageKHR
gpointer
gst_egl_image_get_image (GstEGLImage * image)
{
g_return_val_if_fail (GST_IS_EGL_IMAGE (image), EGL_NO_IMAGE_KHR);
Expand Down Expand Up @@ -151,7 +158,7 @@ _gst_egl_image_copy (GstMiniObject * obj)
* Returns: a new #GstEGLImage wrapping @image
*/
GstEGLImage *
gst_egl_image_new_wrapped (GstGLContext * context, EGLImageKHR image,
gst_egl_image_new_wrapped (GstGLContext * context, gpointer image,
GstGLFormat format, gpointer user_data,
GstEGLImageDestroyNotify user_data_destroy)
{
Expand Down
13 changes: 5 additions & 8 deletions gst-libs/gst/gl/egl/gsteglimage.h
Expand Up @@ -23,11 +23,8 @@
#ifndef _GST_EGL_IMAGE_H_
#define _GST_EGL_IMAGE_H_

#include <gst/gst.h>
#include <gst/video/video.h>

#include <gst/gl/gl.h>
#include <gst/gl/egl/gstegl.h>
#include <gst/gl/gstgl_fwd.h>
#include <gst/gl/gstglformat.h>

G_BEGIN_DECLS

Expand Down Expand Up @@ -61,7 +58,7 @@ struct _GstEGLImage
GstMiniObject parent;

GstGLContext *context;
EGLImageKHR image;
gpointer image;
GstGLFormat format;

/* <private> */
Expand All @@ -73,12 +70,12 @@ struct _GstEGLImage

GST_EXPORT
GstEGLImage * gst_egl_image_new_wrapped (GstGLContext * context,
EGLImageKHR image,
gpointer image,
GstGLFormat format,
gpointer user_data,
GstEGLImageDestroyNotify user_data_destroy);
GST_EXPORT
EGLImageKHR gst_egl_image_get_image (GstEGLImage * image);
gpointer gst_egl_image_get_image (GstEGLImage * image);

GST_EXPORT
GstEGLImage * gst_egl_image_from_texture (GstGLContext * context,
Expand Down
22 changes: 12 additions & 10 deletions gst-libs/gst/gl/egl/gstglcontext_egl.c
Expand Up @@ -29,10 +29,13 @@
*/

#include "gstglcontext_egl.h"
#include <gst/gl/egl/gstegl.h>

#include <gst/gl/gstglcontext_private.h>
#include <gst/gl/gstglfeature.h>

#include "gstegl.h"
#include "../utils/opengl_versions.h"
#include "../utils/gles_versions.h"
#include "../gstglcontext_private.h"

#if GST_GL_HAVE_WINDOW_X11
#include "../x11/gstglwindow_x11.h"
Expand Down Expand Up @@ -281,7 +284,7 @@ gst_gl_context_egl_create_context (GstGLContext * context,
{
GstGLContextEGL *egl;
GstGLWindow *window = NULL;
EGLNativeWindowType window_handle = (EGLNativeWindowType) 0;
guintptr window_handle = 0;
EGLint egl_major;
EGLint egl_minor;
gboolean need_surface = TRUE;
Expand Down Expand Up @@ -520,15 +523,14 @@ gst_gl_context_egl_create_context (GstGLContext * context,
}

if (window)
window_handle =
(EGLNativeWindowType) gst_gl_window_get_window_handle (window);
window_handle = gst_gl_window_get_window_handle (window);

if (window_handle) {
GST_DEBUG ("Creating EGLSurface from window_handle %p",
(void *) window_handle);
egl->egl_surface =
eglCreateWindowSurface (egl->egl_display, egl->egl_config,
window_handle, NULL);
(EGLNativeWindowType) window_handle, NULL);
/* Store window handle for later comparision */
egl->window_handle = window_handle;
} else if (!gst_gl_check_extension ("EGL_KHR_surfaceless_context",
Expand Down Expand Up @@ -619,10 +621,10 @@ gst_gl_context_egl_activate (GstGLContext * context, gboolean activate)

if (activate) {
GstGLWindow *window = gst_gl_context_get_window (context);
EGLNativeWindowType handle = 0;
guintptr handle = 0;
/* Check if the backing handle changed */
if (window) {
handle = (EGLNativeWindowType) gst_gl_window_get_window_handle (window);
handle = gst_gl_window_get_window_handle (window);
gst_object_unref (window);
}
if (handle && handle != egl->window_handle) {
Expand All @@ -639,8 +641,8 @@ gst_gl_context_egl_activate (GstGLContext * context, gboolean activate)
}
}
egl->egl_surface =
eglCreateWindowSurface (egl->egl_display, egl->egl_config, handle,
NULL);
eglCreateWindowSurface (egl->egl_display, egl->egl_config,
(EGLNativeWindowType) handle, NULL);
egl->window_handle = handle;

if (egl->egl_surface == EGL_NO_SURFACE) {
Expand Down
15 changes: 6 additions & 9 deletions gst-libs/gst/gl/egl/gstglcontext_egl.h
Expand Up @@ -21,10 +21,7 @@
#ifndef __GST_GL_EGL_H__
#define __GST_GL_EGL_H__

#include <gst/gst.h>
#include <gst/gl/gl.h>
#include <gst/gl/egl/gstegl.h>

#include <gst/gl/gstglcontext.h>
#include <gst/gl/egl/gstgldisplay_egl.h>

G_BEGIN_DECLS
Expand Down Expand Up @@ -57,10 +54,10 @@ struct _GstGLContextEGL

GstGLDisplayEGL *display_egl;

EGLContext egl_context;
EGLDisplay egl_display;
EGLSurface egl_surface;
EGLConfig egl_config;
gpointer egl_context;
gpointer egl_display;
gpointer egl_surface;
gpointer egl_config;

gint egl_major;
gint egl_minor;
Expand All @@ -70,7 +67,7 @@ struct _GstGLContextEGL
const gchar *egl_exts;

/* Cached handle */
EGLNativeWindowType window_handle;
guintptr window_handle;
};

/**
Expand Down

0 comments on commit 4952fdd

Please sign in to comment.