Commit graph

90 commits

Author SHA1 Message Date
Tim-Philipp Müller d736bfc855 gl: Update for g_type_class_add_private() deprecation in recent GLib
https://gitlab.gnome.org/GNOME/glib/merge_requests/7
2018-06-23 22:58:44 +02:00
Carlos Rafael Giani 4df219f336 gl: Add Mesa3D GBM backend
This makes it possible to use the GStreamer OpenGL elements without a
windowing system if a libdrm- and Mesa3D-supported GPU is present

https://bugzilla.gnome.org/show_bug.cgi?id=782923
2018-02-23 21:09:45 -05:00
Nicolas Dufresne 17b118c120 glimagesink: Allow resetting render rectangle
As documented, passing -1 to x and/or y should reset the render
rectangle to the window/display size.

https://bugzilla.gnome.org/show_bug.cgi?id=792798
2018-01-30 09:58:14 +00:00
Tim-Philipp Müller 0dd66648c3 gl: fix up a few more #if HAVE_FOO
error: "HAVE_PNG" is not defined, evaluates to 0 [-Werror=undef]
2017-12-19 16:51:24 +00:00
Tim-Philipp Müller 1ddde50048 gl: make some debug categories private
They weren't supposed to be public.

https://bugzilla.gnome.org/show_bug.cgi?id=786170
2017-12-09 19:32:29 +00:00
Tim-Philipp Müller 4be04f8315 gl: don't export symbols that are not supposed to be public
Make a bunch of symbols private that are currently leaked
accidentally because they have a gst_* prefix and are used
internally. We mark those we can't make static with
G_GNUC_INTERNAL so that they get hidden with the autotools
build as well (although we could just pass -fvisibility=hidden
there too).
2017-12-09 19:32:29 +00:00
Carlos Rafael Giani cdd4f4532c gl/viv-fb: Fix user-choice string comparisons
https://bugzilla.gnome.org/show_bug.cgi?id=782921
2017-12-09 19:32:28 +00:00
Matthew Waters 4c75bab70d glcontext: add public swap_buffers function
That simply calls the implementation
2017-12-09 19:32:28 +00:00
Sebastian Dröge a9a05c01a9 gst: Clear floating flag in constructor of all GstObject subclasses that are not owned by any parent
https://bugzilla.gnome.org/show_bug.cgi?id=743062
2017-12-09 19:32:28 +00:00
Sebastian Dröge ed7c9f70d9 gl: Add support for Vivante EGL FB windowing system
This is very similar to how dispmanx on the Raspberry Pi works.

Based on a patch by Haihua Hu <b55597@freescale.com> from
https://github.com/Freescale/meta-freescale/tree/master/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad

https://bugzilla.gnome.org/show_bug.cgi?id=778825
2017-12-09 19:32:26 +00:00
Matthew Waters fe3298993b gl/window: remove unused priv variable
https://ci.gstreamer.net/job/GStreamer-master/7989/console
2017-12-09 19:32:25 +00:00
Matthew Waters f532e699df gl/window: remove use of main_context_push/pop_thread_default()
No-one's using/depending on it (it would have criticalled and not worked)
and it's causing more problems than it's solving.  Store the GMainContext
in the public struct instead for subclasses to optionally use instead of
relying on the push/pop state to be correct.

https://bugzilla.gnome.org/show_bug.cgi?id=775970
2017-12-09 19:32:25 +00:00
Matthew Waters 7306f2de2c glwindow: move g_main_context_push/pop_thread_default() to run()
Calling g_main_context_push_thread and then g_main_context_invoke()
(used by gst_gl_window_send_message_async()) in the same thread will
cause the invoked function to run immediately instead of being delayed.

This had implications for the creation of the OpenGL context not waiting
until the main loop had completely started up and as a result would
sometimes deadlock in short create/destroy scenarios.

https://bugzilla.gnome.org/show_bug.cgi?id=775171
2017-12-09 19:32:25 +00:00
Matthew Waters 2b89a2c348 glwindow: remove is_running() function
It isn't necessary in correctly written programs.
2017-12-09 19:32:24 +00:00
Matthew Waters 4abca9f5d0 glwindow: remove the navigation thread
This functionality can now effectively be implemented with the display event
thread.
2017-12-09 19:32:24 +00:00
Matthew Waters 62d0bac993 gl/gi: some annotation updates for called functions
With scope, closure, destroy annotations
2017-12-09 19:32:23 +00:00
Matthew Waters 18ac98c58b gl: GST_GL_TYPE -> GST_TYPE_GL
Some deprecated symbols are kept for backwards compatibility
2017-12-09 19:32:23 +00:00
Matthew Waters 126ee924c0 glwindow: don't use g_thread_join() to join the navigation thread
Using g_thread_join() in _finalize() handlers may result in a deadlock
joining the current thread when the last reference is held by a signal
handler.

e.g.:

error 'Resource deadlock avoided' during 'pthread_join (pt->system_thread, NULL)'

The backtrace looks like this:
[...]
g_thread_join ()
gst_gl_window_finalize ()
gst_gl_window_x11_finalize ()
g_object_unref ()
g_value_unset ()
g_signal_emit_valist ()
g_signal_emit ()
gst_gl_window_send_mouse_event ()
gst_gl_window_mouse_event_cb ()
g_main_dispatch ()
[..]
g_main_loop_run ()
gst_gl_window_navigation_thread ()
g_thread_proxy ()
start_thread ()
clone ()
2017-12-09 19:32:23 +00:00
Matthew Waters 792299d9ae glwindow: marshal gst_gl_window_resize through the window loop
saves having every caller do it themselves.
2017-12-09 19:32:22 +00:00
Matthew Waters 85d5489f58 glwindow: move unsetting queue_resize to _resize() instead of _draw()
Makes infinitely more sense and implementation were expecting that behaviour
anyway and would enter a resize, draw, resize, draw, ... cycle instead of only
resizing once.
2017-12-09 19:32:21 +00:00
Alessandro Decina 3d124f498a glwindow: reduce the number of GMutexes and GConds in send_message()
Don't create many short lived locks/conds in gst_gl_window_send_message. This is
a micro optimization to save a bunch of pthread_* calls which are expensive on
OSX/iOS and possibly other platforms.
2017-12-09 19:32:19 +00:00
Julien Isorce f2cfa7fb51 gstglwindow: initialize navigation_loop to NULL
Useful when gst_gl_window.c::gst_gl_window_new is not used.
This is the case when using a custom GstGLWindow.
(ex: GstGLWindowGPUProcess from Chromium)
2017-12-09 19:32:16 +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
Sebastian Dröge 8b00b1347e glwindow: Use g_thread_join() instead of a custom condition variable for waiting for the navigation thread to finish
Also hide some internal functions and fields while we're at it and fix
a race condition with the startup condition variable.
2017-12-09 19:32:13 +00:00
Haihua Hu 9fcf5500b2 glwindow: Fix memory leak of navigation thread
When stopping the navigation thread, call g_thread_join() to release
the resources hold by it.

https://bugzilla.gnome.org/show_bug.cgi?id=758820
2017-12-09 19:32:13 +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
Jan Schmidt 6b67fdf2ef glwindow: Fix g_return_val_if_fail in a void function 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 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
Julien Isorce 210d2c2825 glwindow: move main loop/context creation back to init/finalize
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=750199
2017-12-09 19:32:03 +00:00
Matthew Waters fea0b65eb5 glwindow: fix compiler error
gstglwindow.c:1118:544: error: 'return' with no value, in function returning non-void [-Werror]
   g_return_if_fail (GST_GL_IS_WINDOW (window));
2017-12-09 19:32:03 +00:00
Matthew Waters 6c56aba687 glwindow: handle gst_video_overlay_set_render_rectangle 2017-12-09 19:32:03 +00:00
Julien Isorce 2efeb71c83 glwindow_x11: use parent default implementation 2017-12-09 19:32:02 +00:00
Julien Isorce 01961ec44d glwindow: initialize debug in class_init
Useful if one uses gst_gl_window_x11_new directly
instead of gst_gl_window_new.
2017-12-09 19:32:02 +00:00
Julien Isorce 2472bcaaa6 glwindow: provides some default implementations to factorize with all backends 2017-12-09 19:32:02 +00:00
Matthew Waters 6445569abf glwindow: track context activation properly
We only need to deactivate/reactivate the context iff it was already
active.
2017-12-09 19:31:59 +00:00
Julien Isorce 0142f551f8 glwindow: remove unused gl_thread field 2017-12-09 19:31:58 +00:00
Edward Hervey 961e847433 gl: Fix context leaks
Introduced by a12ca13750
2017-12-09 19:31:56 +00:00
Edward Hervey 081f101f56 glwindow: Deactivate window before changing handle
When setting a new window handle, we need to ensure all implementations
will detect the change.

For that we deactivate the context before setting the window handle, then
reactivate the context

https://bugzilla.gnome.org/show_bug.cgi?id=745090
2017-12-09 19:31:55 +00:00
Sebastian Dröge c4e75844a8 glwindow: Remove assertion in gst_gl_window_show() for subclasses not implementing it
On Android and iOS we can't create a window ourselves, so also can't just show
one. That's not a problem and an assertion is not really needed here.
2017-12-09 19:31:54 +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
Hyunjun Ko db6ea1b3bd gl: Correct invalid comment text 2017-12-09 19:31:49 +00:00
Julien Isorce af59b771fd gl: do not raise a critical msg if the backend does not handle window events
Fix "assertion 'window_class->handle_events != NULL' failed"
if not using a X11 window.
2017-12-09 19:31:49 +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
Tim-Philipp Müller 653c04b121 gl: fix Since marker for gst_gl_window_run_navigation() 2017-12-09 19:31:49 +00:00
Matthew Waters 35e9b5ab8b gl: sprinkle some Since markers 2017-12-09 19:31:49 +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
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