From: Matthew Waters Date: Thu, 13 Jun 2013 07:57:35 +0000 (+1000) Subject: [708/906] display: a cleanup and removal of old code X-Git-Tag: 1.19.3~511^2~1989^2~1832 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e86d0e920ccc70f1c4f3a8852509bbf24c599b2;p=platform%2Fupstream%2Fgstreamer.git [708/906] display: a cleanup and removal of old code --- diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c index 1442853..b4623dd 100644 --- a/gst-libs/gst/gl/gstgldisplay.c +++ b/gst-libs/gst/gl/gstgldisplay.c @@ -3,6 +3,7 @@ * Copyright (C) 2007 David A. Schleef * Copyright (C) 2008 Julien Isorce * Copyright (C) 2008 Filippo Argiolas + * Copyright (C) 2013 Matthew Waters * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -51,19 +52,12 @@ G_DEFINE_TYPE_WITH_CODE (GstGLDisplay, gst_gl_display, G_TYPE_OBJECT, DEBUG_INIT); #define GST_GL_DISPLAY_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_DISPLAY, GstGLDisplayPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_DISPLAY, GstGLDisplayPrivate)) static void gst_gl_display_finalize (GObject * object); -/* Called in the gl thread, protected by lock and unlock */ -gpointer gst_gl_display_thread_create_context (GstGLDisplay * display); -void gst_gl_display_thread_destroy_context (GstGLDisplay * display); -void gst_gl_display_thread_run_generic (GstGLDisplay * display); - struct _GstGLDisplayPrivate { - GstGLWindow *window; - /* generic gl code */ GstGLDisplayThreadFunc generic_callback; gpointer data; @@ -86,11 +80,10 @@ gst_gl_display_init (GstGLDisplay * display) { display->priv = GST_GL_DISPLAY_GET_PRIVATE (display); - /* thread safe */ - g_mutex_init (&display->mutex); - display->gl_vtable = g_slice_alloc0 (sizeof (GstGLFuncs)); + display->gl_api = GST_GL_API_NONE; + gst_gl_memory_init (); } @@ -99,27 +92,19 @@ gst_gl_display_finalize (GObject * object) { GstGLDisplay *display = GST_GL_DISPLAY (object); - g_mutex_clear (&display->mutex); - if (display->gl_vtable) { g_slice_free (GstGLFuncs, display->gl_vtable); display->gl_vtable = NULL; } - if (display->priv->window) { - gst_object_unref (display->priv->window); - display->priv->window = NULL; + if (display->window) { + gst_object_unref (display->window); + display->window = NULL; } G_OBJECT_CLASS (gst_gl_display_parent_class)->finalize (object); } -//------------------------------------------------------------ -//------------------ BEGIN GL THREAD PROCS ------------------- -//------------------------------------------------------------ - -/* Called in the gl thread */ - void gst_gl_display_thread_run_generic (GstGLDisplay * display) { @@ -129,27 +114,10 @@ gst_gl_display_thread_run_generic (GstGLDisplay * display) display->priv->generic_callback (display, display->priv->data); } -/*------------------------------------------------------------ - --------------------- BEGIN PUBLIC ------------------------- - ----------------------------------------------------------*/ - -void -gst_gl_display_lock (GstGLDisplay * display) -{ - g_mutex_lock (&display->mutex); -} - -void -gst_gl_display_unlock (GstGLDisplay * display) -{ - g_mutex_unlock (&display->mutex); -} - -/* Called by the first gl element of a video/x-raw-gl flow */ GstGLDisplay * gst_gl_display_new (void) { - return g_object_new (GST_GL_TYPE_DISPLAY, NULL); + return g_object_new (GST_TYPE_GL_DISPLAY, NULL); } void @@ -157,7 +125,7 @@ gst_gl_display_thread_add (GstGLDisplay * display, GstGLDisplayThreadFunc func, gpointer data) { g_return_if_fail (GST_IS_GL_DISPLAY (display)); - g_return_if_fail (GST_GL_IS_WINDOW (display->priv->window)); + g_return_if_fail (GST_GL_IS_WINDOW (display->window)); g_return_if_fail (func != NULL); gst_gl_display_lock (display); @@ -165,27 +133,19 @@ gst_gl_display_thread_add (GstGLDisplay * display, display->priv->data = data; display->priv->generic_callback = func; - gst_gl_window_send_message (display->priv->window, + gst_gl_window_send_message (display->window, GST_GL_WINDOW_CB (gst_gl_display_thread_run_generic), display); gst_gl_display_unlock (display); } -guintptr -gst_gl_display_get_internal_gl_context (GstGLDisplay * display) -{ - g_return_val_if_fail (GST_IS_GL_DISPLAY (display), 0); - g_return_val_if_fail (GST_GL_IS_WINDOW (display->priv->window), 0); - - return gst_gl_window_get_gl_context (display->priv->window); -} - GstGLAPI gst_gl_display_get_gl_api (GstGLDisplay * display) { g_return_val_if_fail (GST_IS_GL_DISPLAY (display), GST_GL_API_NONE); + g_return_val_if_fail (GST_GL_IS_WINDOW (display->window), GST_GL_API_NONE); - return display->gl_api; + return gst_gl_window_get_gl_api (display->window); } gpointer @@ -208,10 +168,10 @@ gst_gl_display_set_window (GstGLDisplay * display, GstGLWindow * window) gst_gl_display_lock (display); - if (display->priv->window) - gst_object_unref (display->priv->window); + if (display->window) + gst_object_unref (display->window); - display->priv->window = gst_object_ref (window); + display->window = gst_object_ref (window); gst_gl_display_unlock (display); } @@ -225,8 +185,7 @@ gst_gl_display_get_window (GstGLDisplay * display) gst_gl_display_lock (display); - window = - display->priv->window ? gst_object_ref (display->priv->window) : NULL; + window = display->window ? gst_object_ref (display->window) : NULL; gst_gl_display_unlock (display); @@ -238,5 +197,25 @@ gst_gl_display_get_window_unlocked (GstGLDisplay * display) { g_return_val_if_fail (GST_IS_GL_DISPLAY (display), NULL); - return display->priv->window ? gst_object_ref (display->priv->window) : NULL; + return display->window ? gst_object_ref (display->window) : NULL; +} + +void +gst_context_set_gl_display (GstContext * context, GstGLDisplay * display) +{ + GstStructure *s; + + s = gst_context_writable_structure (context); + gst_structure_set (s, GST_GL_DISPLAY_CONTEXT_TYPE, GST_TYPE_GL_DISPLAY, + display, NULL); +} + +gboolean +gst_context_get_gl_display (GstContext * context, GstGLDisplay ** display) +{ + const GstStructure *s; + + s = gst_context_get_structure (context); + return gst_structure_get (s, GST_GL_DISPLAY_CONTEXT_TYPE, + GST_TYPE_GL_DISPLAY, display, NULL); } diff --git a/gst-libs/gst/gl/gstgldisplay.h b/gst-libs/gst/gl/gstgldisplay.h index dc513db..9d6e895 100644 --- a/gst-libs/gst/gl/gstgldisplay.h +++ b/gst-libs/gst/gl/gstgldisplay.h @@ -3,6 +3,7 @@ * Copyright (C) 2007 David A. Schleef * Copyright (C) 2008 Julien Isorce * Copyright (C) 2008 Filippo Argiolas + * Copyright (C) 2013 Matthew Waters * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -20,53 +21,32 @@ * Boston, MA 02110-1301, USA. */ -#ifndef __GST_GL_H__ -#define __GST_GL_H__ +#ifndef __GST_GL_DISPLAY_H__ +#define __GST_GL_DISPLAY_H__ #include "gstglconfig.h" -#include - -typedef struct _GstGLShader GstGLShader; typedef struct _GstGLWindow GstGLWindow; #include "gstglwindow.h" -#include "gstglshader.h" #include "gstglutils.h" G_BEGIN_DECLS GType gst_gl_display_get_type (void); -#define GST_GL_TYPE_DISPLAY (gst_gl_display_get_type()) -#define GST_GL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_GL_TYPE_DISPLAY,GstGLDisplay)) -#define GST_GL_DISPLAY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_GL_TYPE_DISPLAY,GstGLDisplayClass)) -#define GST_IS_GL_DISPLAY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_GL_TYPE_DISPLAY)) -#define GST_IS_GL_DISPLAY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_GL_TYPE_DISPLAY)) -#define GST_GL_DISPLAY_CAST(obj) ((GstGLDisplay*)(obj)) + +#define GST_TYPE_GL_DISPLAY (gst_gl_display_get_type()) +#define GST_GL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY,GstGLDisplay)) +#define GST_GL_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_DISPLAY,GstGLDisplayClass)) +#define GST_IS_GL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY)) +#define GST_IS_GL_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY)) +#define GST_GL_DISPLAY_CAST(obj) ((GstGLDisplay*)(obj)) typedef struct _GstGLDisplay GstGLDisplay; typedef struct _GstGLDisplayClass GstGLDisplayClass; typedef struct _GstGLDisplayPrivate GstGLDisplayPrivate; /** - * GstGLDisplayConversion: - * - * %GST_GL_DISPLAY_CONVERSION_GLSL: Convert using GLSL (shaders) - * %GST_GL_DISPLAY_CONVERSION_MATRIX: Convert using the ARB_imaging extension (not implemented) - * %GST_GL_DISPLAY_CONVERSION_MESA: Convert using support in MESA - */ -typedef enum -{ - GST_GL_DISPLAY_CONVERSION_GLSL, - GST_GL_DISPLAY_CONVERSION_MATRIX, - GST_GL_DISPLAY_CONVERSION_MESA, -} GstGLDisplayConversion; - - -/** * GstGLDisplayThreadFunc: * @display: a #GstGLDisplay * @data: user data @@ -83,22 +63,17 @@ typedef void (*GstGLDisplayThreadFunc) (GstGLDisplay * display, gpointer data); */ struct _GstGLDisplay { - GObject object; + GstObject object; - /* thread safe */ - GMutex mutex; + /* */ + GstGLWindow *window; + GstGLAPI gl_api; - /* gl API we are using */ - GstGLAPI gl_api; - /* foreign gl context */ - gulong external_gl_context; + GstGLFuncs *gl_vtable; - GstGLFuncs *gl_vtable; - - GstGLDisplayPrivate *priv; + GstGLDisplayPrivate *priv; }; - struct _GstGLDisplayClass { GObjectClass object_class; @@ -106,21 +81,24 @@ struct _GstGLDisplayClass GstGLDisplay *gst_gl_display_new (void); -void gst_gl_display_thread_add (GstGLDisplay * display, - GstGLDisplayThreadFunc func, gpointer data); +#define gst_gl_display_lock(display) GST_OBJECT_LOCK (display) +#define gst_gl_display_unlock(display) GST_OBJECT_UNLOCK (display) -gulong gst_gl_display_get_internal_gl_context (GstGLDisplay * display); +GstGLAPI gst_gl_display_get_gl_api (GstGLDisplay * display); +gpointer gst_gl_display_get_gl_vtable (GstGLDisplay * display); +void gst_gl_display_set_window (GstGLDisplay * display, GstGLWindow * window); +GstGLWindow * gst_gl_display_get_window (GstGLDisplay * display); +GstGLWindow * gst_gl_display_get_window_unlocked (GstGLDisplay * display); -void gst_gl_display_lock (GstGLDisplay * display); -void gst_gl_display_unlock (GstGLDisplay * display); -GstGLAPI gst_gl_display_get_gl_api (GstGLDisplay * display); - -gpointer gst_gl_display_get_gl_vtable (GstGLDisplay * display); +void gst_gl_display_thread_add (GstGLDisplay * display, + GstGLDisplayThreadFunc func, gpointer data); -void gst_gl_display_set_window (GstGLDisplay * display, GstGLWindow * window); -GstGLWindow * gst_gl_display_get_window (GstGLDisplay * display); -GstGLWindow * gst_gl_display_get_window_unlocked (GstGLDisplay * display); +#define GST_GL_DISPLAY_CONTEXT_TYPE "gst.gl.GLDisplay" +void gst_context_set_gl_display (GstContext * context, + GstGLDisplay * display); +gboolean gst_context_get_gl_display (GstContext * context, + GstGLDisplay ** display); G_END_DECLS -#endif /* __GST_GL_H__ */ +#endif /* __GST_GL_DISPLAY_H__ */ diff --git a/gst-libs/gst/gl/gstglmixerpad.h b/gst-libs/gst/gl/gstglmixerpad.h index cb254ec..682bf00 100644 --- a/gst-libs/gst/gl/gstglmixerpad.h +++ b/gst-libs/gst/gl/gstglmixerpad.h @@ -25,7 +25,7 @@ #include #include "gstgldisplay.h" -#include +#include "gstglupload.h" G_BEGIN_DECLS diff --git a/gst-libs/gst/gl/gstglutils.h b/gst-libs/gst/gl/gstglutils.h index aba5001..569a8f0 100644 --- a/gst-libs/gst/gl/gstglutils.h +++ b/gst-libs/gst/gl/gstglutils.h @@ -22,8 +22,12 @@ #define __GST_GL_UTILS_H__ typedef struct _GstGLDisplay GstGLDisplay; +typedef struct _GstGLShader GstGLShader; + +#include #include "gstgldisplay.h" +#include "gstglshader.h" /** * GstGLDisplayProjection: diff --git a/gst-libs/gst/gl/gstglwindow.c b/gst-libs/gst/gl/gstglwindow.c index 5488a6c..51b9928 100644 --- a/gst-libs/gst/gl/gstglwindow.c +++ b/gst-libs/gst/gl/gstglwindow.c @@ -385,20 +385,13 @@ gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback, GstGLAPI gst_gl_window_get_gl_api (GstGLWindow * window) { - GstGLAPI ret; GstGLWindowClass *window_class; g_return_val_if_fail (GST_GL_IS_WINDOW (window), GST_GL_API_NONE); window_class = GST_GL_WINDOW_GET_CLASS (window); g_return_val_if_fail (window_class->get_gl_api != NULL, GST_GL_API_NONE); - GST_GL_WINDOW_LOCK (window); - - ret = window_class->get_gl_api (window); - - GST_GL_WINDOW_UNLOCK (window); - - return ret; + return window_class->get_gl_api (window); } gpointer