Commit graph

91 commits

Author SHA1 Message Date
Haihua Hu 4cd94ddd25 glwindow: Fix glimagesink cannot show frame when connect to qmlglsrc
When connect to qmlglsrc, x11 event loop will be replace by qt event loop
which will cause the window cannot receive event from xserver, such as resize

https://bugzilla.gnome.org/show_bug.cgi?id=768160
2017-12-09 19:32:21 +00:00
Matthew Waters d5913f3048 gl/x11/navigation: add button press to the selected event mask
Otherwise we won't get the button press events and GstNavigation fails.
2017-12-09 19:32:14 +00:00
Sebastian Dröge 1403a6871f glwindow: Hide navigation specific internal API and add API to asynchronously send navigation events
Exposing the navigation thread's main context, GSourceFuncs and structs called
key_event and mouse_event is exposing a bit too much of the internals. Let's
just go with two functions to asynchronously send navigation events on the
window with the same API as the synchronous ones.
2017-12-09 19:32:13 +00:00
Reynaldo H. Verdejo Pinochet 68e668168d Remove unnecessary NULL checks before g_free()
g_free() is NULL-safe
2017-12-09 19:32:11 +00:00
Matthew Waters 06de6998e5 gl: be consistent in gobject boilerpate
GST_GL_IS_* vs GST_IS_GL_*

git grep -l 'GST_GL_IS_' | xargs sed -i 's/GST_GL_IS_/GST_IS_GL_/g'
2017-12-09 19:32:09 +00:00
Matthew Waters e9864e2e3e glwindow: remove unused draw_unlocked function
The functionality is provided by draw anyway and is leftover from
X11's specific threading requirements that no longer apply.
2017-12-09 19:32:08 +00:00
Matthew Waters 63bbe9406a glwindow: add API to request a resize event on the next draw
- glimagesink needs to be able to resize the viewport on aspect ratio
  changes resulting from either caps changes or 3d output mode changes.
- Performing a glViewport outside the GstGLWindow::resize callback
  will not have the winsys' stack of viewports required to correctly
  place the output frame.

Provide a function to request a resize on the next draw event from the
winsys.

Also track size changes inside the base GstGLWindow class rather
than in each subclass.

https://bugzilla.gnome.org/show_bug.cgi?id=755111
2017-12-09 19:32:08 +00:00
Matthew Waters a18cdf4781 gl/x11: store the correct dimension from the resize events
small typo s/width/height/
2017-12-09 19:32:08 +00:00
Matthew Waters 6589c38d1a glcontext/wgl: implement gl3 core profile context selection 2017-12-09 19:32:07 +00:00
Matthew Waters 2034f78617 context/glx: only use glXCreateContextAttribs for OpenGL 3 contexts
mesa for example when creating a GL 3.1 compatibility context
overrides our context profile selection to create a core context.
2017-12-09 19:32:07 +00:00
Matthew Waters 6ccaafc0f3 glwindow: pass display to implementation's _new()
So they have to opportunity to fail if they cannot handle the
display connection.

https://bugzilla.gnome.org/show_bug.cgi?id=752743
2017-12-09 19:32:07 +00:00
Matthew Waters 9587eb477d glcontext: pass display to implentation's _new()
This allows the context to fail creation based on incompatible
display type's. e.g. glx context with an wayland display handle.

https://bugzilla.gnome.org/show_bug.cgi?id=752743
2017-12-09 19:32:06 +00:00
Matthew Waters cfa9b94045 glcontext: consolidate get_proc_address function definition
Pass the GstGLAPI directly.
2017-12-09 19:32:05 +00:00
Matthew Waters 3343e2dccd glcontext/glx: try creating a context with the highest version
nvidia drivers return the exact version in glGstString (GL_VERSION)
we request on creation so start with the highest known version and
work our way down.
2017-12-09 19:32:05 +00:00
Sebastian Dröge 5df0fbfbca Revert "gl/window/x11: don't create our own X11 display"
This reverts commit 5697b6b89b.

https://bugzilla.gnome.org/show_bug.cgi?id=751003
2017-12-09 19:32:05 +00:00
Matthew Waters 9900928403 gl/window/x11: only listen on the X Display when needed
5697b6b89b causes us to possibly listen
on a toolkit provided Display connection.  We thus could eat their
precious winsys events.  Only listen if we need to
(!foreign_display or videooverlay).
2017-12-09 19:32:04 +00:00
Matthew Waters 1f7025c585 gl/window/x11: don't create our own X11 display
It's not needed anymore with most window operations occuring in the
GL thread.
2017-12-09 19:32:04 +00:00
Matthew Waters e37cf3c55f gl/window/x11: handle_events() may be called before the window has been created
Fixes an XIO fatal error
2017-12-09 19:32:04 +00:00
Julien Isorce 2efeb71c83 glwindow_x11: use parent default implementation 2017-12-09 19:32:02 +00:00
Julien Isorce fa7aafb4ff glcontext_glx: rename variable from window to context 2017-12-09 19:32:02 +00:00
Matthew Waters 39eb34eb43 gl/x11: don't XGetWindowAttributes every XEvent
fixes a deadlock in xcb where the X window may not exist.

https://bugzilla.gnome.org/show_bug.cgi?id=745633
2017-12-09 19:31:56 +00:00
Matthew Waters 5b8f3e7870 gl/window: create the main loop/context on init/finalize
Avoids races setting the window handle from the main thread.

https://bugzilla.gnome.org/show_bug.cgi?id=745633
2017-12-09 19:31:56 +00:00
Matthew Waters 598715fc4b glwindow: make showing a window explicit
Also fixes the cgl context always displaying a window to render to for
every GstGLContextCocoa created
2017-12-09 19:31:53 +00:00
Matthew Waters 019367c128 glwindow: remove width/height from _draw()
Depending on the platform, it was only ever implemented to 1) set a
default surface size, 2) resize based on the video frame or 3) nothing.
Instead, provide a set_preferred_size () that elements/applications
can use to request a certain size which may be ignored for
videooverlay/other cases.
2017-12-09 19:31:53 +00:00
Matthew Waters 86c084f1af glx: ask for a GL3 core context 2017-12-09 19:31:50 +00:00
Lubosz Sarnecki 64dd17bde6 glimagesink: implement gst_video_overlay_handle_events
https://bugzilla.gnome.org/show_bug.cgi?id=736035
2017-12-09 19:31:49 +00:00
Matthew Waters 7d97a35139 glcontext: add more functionality to wrapped contexts
Implements get_current_context() and get_proc_address() for wrapped
contexts.
2017-12-09 19:31:49 +00:00
Matthew Waters be5d0d81e4 glcontext: add api for retreiving the current context and api
that is current in the calling thread.
2017-12-09 19:31:48 +00:00
Vasilis Liaskovitis f803a9e746 GstGLWindow: Introduce navigation thread
This thread dispatches navigation events. It is needed to avoid deadlocks
between window backend threads that emit navigation events (e.g. X11/GMainLoop
thread) and consumers of navigation events such as glimagesink, see
https://bugzilla.gnome.org/show_bug.cgi?id=733661

GstGlWindow_x11 thread is changed to invoke the navigation thread for navigation
dispatching, instead of emiting the event itself. Othe backends beside X11 do
not dispatch navigation events yet, but should use this thread when dispatching
these events in the future.

The navigation thread is currently part of GstGLWindow and not implemented in
separate subclasses / backends. This will be needed in the future.

gst_gl_window_x11_get_surface_dimensions is also changed to use a cached value
of the window's width, height. These values are now retrieved in the X11
thread, function gst_gl_window_x11_handle_event. This change is needed because
otherwise the XGetWindowAttributes gets called from the navigation thread,
leading to xlib aborting due to multithreaded access (if XInitThreads is not
called before, as is the case for gst-launch)
2017-12-09 19:31:46 +00:00
Matthew Waters 61b95b0300 glcontext: implement the debug callback
For both GL_KHR_debug and ARB_debug_output.  This allows us to
receive errors and other hints from the GL instead of querying after
every GL operation.
2017-12-09 19:31:45 +00:00
Vasilis Liaskovitis 7b1a853888 GstGLWindow, GstGLImagesink, x11: Scale navigation events on resized windows
If window is resized, GstStructure pointer values have to be rescaled to
original geometry. A get_surface_dimensions GLWindow class method is added for
this purpose and used in the navigation send_event function.

https://bugzilla.gnome.org/show_bug.cgi?id=703486
2017-12-09 19:31:45 +00:00
Matthew Waters d3077a890c gl/x11: silence runtime warning
g_main_loop_quit: assertion 'loop != NULL' failed
2017-12-09 19:31:45 +00:00
Vasilis Liaskovitis b1e821f731 glwindow/11: Emit signals for mouse and key navigation events
https://bugzilla.gnome.org/show_bug.cgi?id=703486
2017-12-09 19:31:44 +00:00
Matthew Waters 384434b060 glwindow_x11: allow expose events to redraw our window
otherwise we will not update the window contents on low framerate
streams until the next buffer

https://bugzilla.gnome.org/show_bug.cgi?id=723529
2017-12-09 19:31:42 +00:00
Matthew Waters e502311ce4 gl/window_x11: avoid BadDrawable error on shutdown 2017-12-09 19:31:41 +00:00
Sebastian Dröge 8c56e1bba7 gl: Try harder to load symbols from the correct place
This commit makes the loading of the GModules threadsafe, and
always first tries to load the symbol for the GL library that
is selected for the current context. Only then it falls back
to looking into the current module (NULL), and only as a last
resort the context specific function (e.g. eglGetProcAddress())
is called.

Also add configure parameters to select the names of the library
modules instead of using the defaults, and let the defaults be
independent of the G_MODULE_SUFFIX.

https://bugzilla.gnome.org/show_bug.cgi?id=728753
2017-12-09 19:31:38 +00:00
Nicolas Dufresne 801f11e36b gl/x11: Removed unused variable 2017-12-09 19:31:37 +00:00
Sebastian Dröge 8f156591e5 gl/x11: Get rid of unneeded second display connection and do everything from the main loop 2017-12-09 19:31:37 +00:00
Sebastian Dröge a0a133288e gl/x11: Block rendering until swapbuffers is called and don't go via X11 events as unneeded indirection
This should fix QoS problems, where basesink believed it was rendering with
20FPS but actually we were just queueing up X11 Expose events and only once
in a while something was rendered.
2017-12-09 19:31:37 +00:00
Matthew Waters ff52514714 gl/glx: use the context's display rather than asking for the window's 2017-12-09 19:31:35 +00:00
Julien Isorce f55e8b3ea8 gl: remove commented and unsued code in x11 Makefile.am
https://bugzilla.gnome.org/show_bug.cgi?id=703343
2017-12-09 19:31:35 +00:00
Gwenole Beauchesne 14521a89cb gl: fix out-of-source builds.
Always use the locally generated <gst/gl/gstglconfig.h> file.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2017-12-09 19:31:35 +00:00
Matthew Waters 0fa966bb3d gl: remove explicit reference to X_CFLAGS
They are in GL_CFLAGS if required
2017-12-09 19:31:35 +00:00
Matthew Waters e225af3e0d gl: silence all the compiler warnings 2017-12-09 19:31:34 +00:00
Matthew Waters 6300c2ef1b [901/906] glx: use the display handle from the global display
Intel drivers require the display handles be the same for context
sharing to occur.  Also solves some cases of use after free of the
display when integrating with gstreamer-vaapi.

See https://bugs.freedesktop.org/show_bug.cgi?id=41736 for the intel bug.
2017-12-09 19:31:34 +00:00
Matthew Waters 8f29fffc2f [893/906] x11: close both of the display's we use
(the comment doesn't seem to apply anymore)

https://bugzilla.gnome.org/show_bug.cgi?id=725048
2017-12-09 19:31:33 +00:00
Matthew Waters 97f6bc0bfc [891/906] context: add support for wrapping external contexts 2017-12-09 19:31:33 +00:00
Matthew Waters 303b77eeff [890/906] x11: add display subclass
GstGLDisplayX11 holds the display connection and name.  Each thread requires
it's own X11 Display connection (initialised from name) due to the fact that
we do not want to call XInitThreads().  Doing so would result in segfaults
when integrating with GUI toolkits Gtk, Qt, etc.

The Display connection is for OpenGL platforms where a constant display is
required in order to share contexts (egl).  In the case of a wrapped context
(added later), we do not have GstGLWindow to retreive the display from so a
'master' connection is used instead.
2017-12-09 19:31:33 +00:00
Chris Paulson-Ellis b6f6d585c3 [877/906] x11: Use correct format string for guintptr
https://bugzilla.gnome.org/show_bug.cgi?id=723537
2017-12-09 19:31:33 +00:00
Matthew Waters 2026f60879 [862/906] window: remove set_need_lock
No-one is using it.  The only code that did was the x11 one which
doesn't need it anymore.
2017-12-09 19:31:33 +00:00