[812/906] move the GL vtable from GstGLDisplay to GstGLContext
authorMatthew Waters <ystreet00@gmail.com>
Sun, 15 Sep 2013 04:23:43 +0000 (14:23 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:31 +0000 (19:31 +0000)
Conflicts:
tests/check/libs/gstglcontext.c

26 files changed:
gst-libs/gst/gl/gstglbufferpool.c
gst-libs/gst/gl/gstglbufferpool.h
gst-libs/gst/gl/gstglcontext.c
gst-libs/gst/gl/gstglcontext.h
gst-libs/gst/gl/gstgldisplay.c
gst-libs/gst/gl/gstgldisplay.h
gst-libs/gst/gl/gstgldownload.c
gst-libs/gst/gl/gstgldownload.h
gst-libs/gst/gl/gstglfeature.c
gst-libs/gst/gl/gstglfeature.h
gst-libs/gst/gl/gstglfilter.c
gst-libs/gst/gl/gstglfilter.h
gst-libs/gst/gl/gstglframebuffer.c
gst-libs/gst/gl/gstglframebuffer.h
gst-libs/gst/gl/gstglmemory.c
gst-libs/gst/gl/gstglmemory.h
gst-libs/gst/gl/gstglmixer.c
gst-libs/gst/gl/gstglmixer.h
gst-libs/gst/gl/gstglshader.c
gst-libs/gst/gl/gstglshader.h
gst-libs/gst/gl/gstglupload.c
gst-libs/gst/gl/gstglupload.h
gst-libs/gst/gl/gstglutils.c
gst-libs/gst/gl/gstglutils.h
tests/check/libs/gstglcontext.c
tests/check/libs/gstglmemory.c

index cef6ea4..74b40b7 100644 (file)
@@ -168,7 +168,7 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
   }
 
   if (!(gl_mem =
-          gst_gl_memory_alloc (glpool->display, GST_VIDEO_INFO_FORMAT (info),
+          gst_gl_memory_alloc (glpool->context, GST_VIDEO_INFO_FORMAT (info),
               GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info))))
     goto mem_create_failed;
   gst_buffer_append_memory (buf, gl_mem);
@@ -206,12 +206,12 @@ mem_create_failed:
  * Returns: a #GstBufferPool that allocates buffers with #GstGLMemory
  */
 GstBufferPool *
-gst_gl_buffer_pool_new (GstGLDisplay * display)
+gst_gl_buffer_pool_new (GstGLContext * context)
 {
   GstGLBufferPool *pool;
 
   pool = g_object_new (GST_TYPE_GL_BUFFER_POOL, NULL);
-  pool->display = gst_object_ref (display);
+  pool->context = gst_object_ref (context);
 
   GST_LOG_OBJECT (pool, "new GL buffer pool %p", pool);
 
@@ -245,9 +245,9 @@ gst_gl_buffer_pool_dispose (GObject * object)
 {
   GstGLBufferPool *pool = GST_GL_BUFFER_POOL_CAST (object);
 
-  if (pool->display) {
-    gst_object_unref (pool->display);
-    pool->display = NULL;
+  if (pool->context) {
+    gst_object_unref (pool->context);
+    pool->context = NULL;
   }
 
   G_OBJECT_CLASS (gst_gl_buffer_pool_parent_class)->dispose (object);
index ab78b83..1fa0628 100644 (file)
@@ -49,7 +49,7 @@ struct _GstGLBufferPool
 {
   GstBufferPool bufferpool;
 
-  GstGLDisplay *display;
+  GstGLContext *context;
 
   GstGLBufferPoolPrivate *priv;
 };
@@ -64,7 +64,7 @@ struct _GstGLBufferPoolClass
   GstBufferPoolClass parent_class;
 };
 
-GstBufferPool *gst_gl_buffer_pool_new (GstGLDisplay * display);
+GstBufferPool *gst_gl_buffer_pool_new (GstGLContext * context);
 
 G_END_DECLS
 
index bbf567b..d6837fe 100644 (file)
@@ -101,6 +101,8 @@ gst_gl_context_init (GstGLContext * context)
 {
   context->priv = GST_GL_CONTEXT_GET_PRIVATE (context);
 
+  context->gl_vtable = g_slice_alloc0 (sizeof (GstGLFuncs));
+
   g_mutex_init (&context->priv->render_lock);
 
   g_cond_init (&context->priv->create_cond);
@@ -196,6 +198,11 @@ gst_gl_context_finalize (GObject * object)
 
   gst_object_unref (context->window);
 
+  if (context->gl_vtable) {
+    g_slice_free (GstGLFuncs, context->gl_vtable);
+    context->gl_vtable = NULL;
+  }
+
   g_mutex_clear (&context->priv->render_lock);
 
   g_cond_clear (&context->priv->destroy_cond);
@@ -367,12 +374,10 @@ static gboolean
 _create_context_gles2 (GstGLContext * context, gint * gl_major, gint * gl_minor,
     GError ** error)
 {
-  GstGLDisplay *display;
   const GstGLFuncs *gl;
   GLenum gl_err = GL_NO_ERROR;
 
-  display = context->priv->display;
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   GST_INFO ("GL_VERSION: %s", gl->GetString (GL_VERSION));
   GST_INFO ("GL_SHADING_LANGUAGE_VERSION: %s",
@@ -394,7 +399,7 @@ _create_context_gles2 (GstGLContext * context, gint * gl_major, gint * gl_minor,
   }
 #endif
 
-  _gst_gl_feature_check_ext_functions (display, 0, 0,
+  _gst_gl_feature_check_ext_functions (context, 0, 0,
       (const gchar *) gl->GetString (GL_EXTENSIONS));
 
   if (gl_major)
@@ -409,14 +414,12 @@ gboolean
 _create_context_opengl (GstGLContext * context, gint * gl_major,
     gint * gl_minor, GError ** error)
 {
-  GstGLDisplay *display;
   const GstGLFuncs *gl;
   guint maj, min;
   GLenum gl_err = GL_NO_ERROR;
   GString *opengl_version = NULL;
 
-  display = context->priv->display;
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   GST_INFO ("GL_VERSION: %s", gl->GetString (GL_VERSION));
   GST_INFO ("GL_SHADING_LANGUAGE_VERSION: %s",
@@ -445,7 +448,7 @@ _create_context_opengl (GstGLContext * context, gint * gl_major,
     return FALSE;
   }
 
-  _gst_gl_feature_check_ext_functions (display, maj, min,
+  _gst_gl_feature_check_ext_functions (context, maj, min,
       (const gchar *) gl->GetString (GL_EXTENSIONS));
 
   if (gl_major)
@@ -541,7 +544,7 @@ gst_gl_context_create_thread (GstGLContext * context)
   }
 
   display = context->priv->display;
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
   compiled_api = _compiled_api ();
 
   user_choice = g_getenv ("GST_GL_API");
@@ -681,3 +684,48 @@ gst_gl_context_get_gl_context (GstGLContext * context)
 
   return result;
 }
+
+GstGLDisplay *
+gst_gl_context_get_display (GstGLContext * context)
+{
+  g_return_val_if_fail (GST_GL_IS_CONTEXT (context), NULL);
+
+  return gst_object_ref (context->priv->display);
+}
+
+typedef struct
+{
+  GstGLContext *context;
+  GstGLContextThreadFunc func;
+  gpointer data;
+} RunGenericData;
+
+static void
+_gst_gl_context_thread_run_generic (RunGenericData * data)
+{
+  GST_TRACE ("running function:%p data:%p", data->func, data->data);
+
+  data->func (data->context, data->data);
+}
+
+void
+gst_gl_context_thread_add (GstGLContext * context,
+    GstGLContextThreadFunc func, gpointer data)
+{
+  GstGLWindow *window;
+  RunGenericData rdata;
+
+  g_return_if_fail (GST_GL_IS_CONTEXT (context));
+  g_return_if_fail (func != NULL);
+
+  rdata.context = context;
+  rdata.data = data;
+  rdata.func = func;
+
+  window = gst_gl_context_get_window (context);
+
+  gst_gl_window_send_message (window,
+      GST_GL_WINDOW_CB (_gst_gl_context_thread_run_generic), &rdata);
+
+  gst_object_unref (window);
+}
index 21db7e8..597f246 100644 (file)
@@ -38,6 +38,15 @@ GType gst_gl_context_get_type     (void);
 #define GST_GL_CONTEXT_ERROR (gst_gl_context_error_quark ())
 GQuark gst_gl_context_error_quark (void);
 
+/**
+ * GstGLContextThreadFunc:
+ * @display: a #GstGLDisplay
+ * @data: user data
+ *
+ * Represents a function to run in the GL thread
+ */
+typedef void (*GstGLContextThreadFunc) (GstGLContext * context, gpointer data);
+
 typedef enum
 {
   GST_GL_CONTEXT_ERROR_FAILED,
@@ -55,6 +64,8 @@ struct _GstGLContext {
   /*< public >*/
   GstGLWindow  *window;
 
+  GstGLFuncs *gl_vtable;
+
   /*< private >*/
   gpointer _reserved[GST_PADDING];
 
@@ -85,6 +96,7 @@ GstGLContext * gst_gl_context_new  (GstGLDisplay *display);
 
 gboolean      gst_gl_context_activate         (GstGLContext *context, gboolean activate);
 
+GstGLDisplay * gst_gl_context_get_display (GstGLContext *context);
 gpointer      gst_gl_context_get_proc_address (GstGLContext *context, const gchar *name);
 GstGLPlatform gst_gl_context_get_platform     (GstGLContext *context);
 GstGLAPI      gst_gl_context_get_gl_api       (GstGLContext *context);
@@ -97,6 +109,10 @@ gpointer      gst_gl_context_default_get_proc_address (GstGLContext *context, co
 gboolean      gst_gl_context_set_window (GstGLContext *context, GstGLWindow *window);
 GstGLWindow * gst_gl_context_get_window (GstGLContext *context);
 
+/* FIXME: remove */
+void gst_gl_context_thread_add (GstGLContext * display,
+    GstGLContextThreadFunc func, gpointer data);
+
 G_END_DECLS
 
 #endif /* __GST_GL_CONTEXT_H__ */
index ed0e886..0bb00d5 100644 (file)
@@ -64,8 +64,6 @@ gst_gl_display_init (GstGLDisplay * display)
 {
   display->priv = GST_GL_DISPLAY_GET_PRIVATE (display);
 
-  display->gl_vtable = g_slice_alloc0 (sizeof (GstGLFuncs));
-
   display->gl_api = GST_GL_API_NONE;
 
   gst_gl_memory_init ();
@@ -76,11 +74,6 @@ gst_gl_display_finalize (GObject * object)
 {
   GstGLDisplay *display = GST_GL_DISPLAY (object);
 
-  if (display->gl_vtable) {
-    g_slice_free (GstGLFuncs, display->gl_vtable);
-    display->gl_vtable = NULL;
-  }
-
   if (display->context) {
     gst_object_unref (display->context);
     display->context = NULL;
@@ -95,45 +88,6 @@ gst_gl_display_new (void)
   return g_object_new (GST_TYPE_GL_DISPLAY, NULL);
 }
 
-#if 1
-typedef struct
-{
-  GstGLDisplay *display;
-  GstGLDisplayThreadFunc func;
-  gpointer data;
-} RunGenericData;
-
-static void
-_gst_gl_display_thread_run_generic (RunGenericData * data)
-{
-  GST_TRACE ("running function:%p data:%p", data->func, data->data);
-
-  data->func (data->display, data->data);
-}
-
-void
-gst_gl_display_thread_add (GstGLDisplay * display,
-    GstGLDisplayThreadFunc func, gpointer data)
-{
-  GstGLWindow *window;
-  RunGenericData rdata;
-
-  g_return_if_fail (GST_IS_GL_DISPLAY (display));
-  g_return_if_fail (GST_GL_IS_CONTEXT (display->context));
-  g_return_if_fail (func != NULL);
-
-  rdata.display = display;
-  rdata.data = data;
-  rdata.func = func;
-
-  window = gst_gl_context_get_window (display->context);
-
-  gst_gl_window_send_message (window,
-      GST_GL_WINDOW_CB (_gst_gl_display_thread_run_generic), &rdata);
-
-  gst_object_unref (window);
-}
-
 GstGLAPI
 gst_gl_display_get_gl_api (GstGLDisplay * display)
 {
@@ -143,15 +97,6 @@ gst_gl_display_get_gl_api (GstGLDisplay * display)
   return gst_gl_context_get_gl_api (display->context);
 }
 
-gpointer
-gst_gl_display_get_gl_vtable (GstGLDisplay * display)
-{
-  g_return_val_if_fail (GST_IS_GL_DISPLAY (display), NULL);
-
-  return display->gl_vtable;
-}
-#endif
-
 void
 gst_gl_display_set_context (GstGLDisplay * display, GstGLContext * context)
 {
index a430a32..604141a 100644 (file)
@@ -38,15 +38,6 @@ GType gst_gl_display_get_type (void);
 #define GST_GL_DISPLAY_CAST(obj)        ((GstGLDisplay*)(obj))
 
 /**
- * GstGLDisplayThreadFunc:
- * @display: a #GstGLDisplay
- * @data: user data
- *
- * Represents a function to run in the GL thread
- */
-typedef void (*GstGLDisplayThreadFunc) (GstGLDisplay * display, gpointer data);
-
-/**
  * GstGLDisplay:
  *
  * the contents of a #GstGLDisplay are private and should only be accessed
@@ -60,8 +51,6 @@ struct _GstGLDisplay
   GstGLContext         *context;
   GstGLAPI              gl_api;
 
-  GstGLFuncs           *gl_vtable;
-
   GstGLDisplayPrivate  *priv;
 };
 
@@ -81,9 +70,6 @@ void           gst_gl_display_set_context             (GstGLDisplay * display, G
 GstGLContext * gst_gl_display_get_context             (GstGLDisplay * display);
 GstGLContext * gst_gl_display_get_context_unlocked    (GstGLDisplay * display);
 
-void gst_gl_display_thread_add (GstGLDisplay * display,
-    GstGLDisplayThreadFunc func, gpointer data);
-
 #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);
index 7439282..663b503 100644 (file)
  * A #GstGLDownload can be created with gst_gl_download_new()
  */
 
-#define USING_OPENGL(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL)
-#define USING_OPENGL3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL3)
-#define USING_GLES(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES)
-#define USING_GLES2(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES2)
-#define USING_GLES3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES3)
-
-static void _do_download (GstGLDisplay * display, GstGLDownload * download);
-static void _init_download (GstGLDisplay * display, GstGLDownload * download);
-static gboolean _init_download_shader (GstGLDisplay * display,
+#define USING_OPENGL(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL)
+#define USING_OPENGL3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL3)
+#define USING_GLES(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES)
+#define USING_GLES2(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2)
+#define USING_GLES3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES3)
+
+static void _do_download (GstGLContext * context, GstGLDownload * download);
+static void _init_download (GstGLContext * context, GstGLDownload * download);
+static gboolean _init_download_shader (GstGLContext * context,
     GstGLDownload * download);
 static gboolean _gst_gl_download_perform_with_data_unlocked (GstGLDownload *
     download, GLuint texture_id, gpointer data[GST_VIDEO_MAX_PLANES]);
 
 #if GST_GL_HAVE_OPENGL
-static void _do_download_draw_rgb_opengl (GstGLDisplay * display,
+static void _do_download_draw_rgb_opengl (GstGLContext * context,
     GstGLDownload * download);
-static void _do_download_draw_yuv_opengl (GstGLDisplay * display,
+static void _do_download_draw_yuv_opengl (GstGLContext * context,
     GstGLDownload * download);
 #endif
 #if GST_GL_HAVE_GLES2
-static void _do_download_draw_rgb_gles2 (GstGLDisplay * display,
+static void _do_download_draw_rgb_gles2 (GstGLContext * context,
     GstGLDownload * download);
-static void _do_download_draw_yuv_gles2 (GstGLDisplay * display,
+static void _do_download_draw_yuv_gles2 (GstGLContext * context,
     GstGLDownload * download);
 #endif
 
@@ -229,8 +229,8 @@ struct _GstGLDownloadPrivate
   const gchar *ARGB;
   const gchar *vert_shader;
 
-  void (*do_rgb) (GstGLDisplay * display, GstGLDownload * download);
-  void (*do_yuv) (GstGLDisplay * display, GstGLDownload * download);
+  void (*do_rgb) (GstGLContext * context, GstGLDownload * download);
+  void (*do_yuv) (GstGLContext * context, GstGLDownload * download);
 
   gboolean result;
 };
@@ -262,7 +262,7 @@ gst_gl_download_init (GstGLDownload * download)
 
   download->priv = GST_GL_DOWNLOAD_GET_PRIVATE (download);
 
-  download->display = NULL;
+  download->context = NULL;
 
   g_mutex_init (&download->lock);
 
@@ -279,23 +279,23 @@ gst_gl_download_init (GstGLDownload * download)
 
 /**
  * gst_gl_download_new:
- * @display: a #GstGLDisplay
+ * @context: a #GstGLContext
  *
  * Returns: a new #GstGLDownload object
  */
 GstGLDownload *
-gst_gl_download_new (GstGLDisplay * display)
+gst_gl_download_new (GstGLContext * context)
 {
   GstGLDownload *download;
   GstGLDownloadPrivate *priv;
 
   download = g_object_new (GST_TYPE_GL_DOWNLOAD, NULL);
 
-  download->display = gst_object_ref (display);
+  download->context = gst_object_ref (context);
   priv = download->priv;
 
 #if GST_GL_HAVE_OPENGL
-  if (USING_OPENGL (display)) {
+  if (USING_OPENGL (context)) {
     priv->YUY2_UYVY = text_shader_YUY2_UYVY_opengl;
     priv->I420_YV12 = text_shader_I420_YV12_opengl;
     priv->AYUV = text_shader_AYUV_opengl;
@@ -306,7 +306,7 @@ gst_gl_download_new (GstGLDisplay * display)
   }
 #endif
 #if GST_GL_HAVE_GLES2
-  if (USING_GLES2 (display)) {
+  if (USING_GLES2 (context)) {
     priv->YUY2_UYVY = text_shader_YUY2_UYVY_gles2;
     priv->I420_YV12 = text_shader_I420_YV12_gles2;
     priv->AYUV = text_shader_AYUV_gles2;
@@ -330,16 +330,17 @@ gst_gl_download_finalize (GObject * object)
 
   for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
     if (download->out_texture[i]) {
-      gst_gl_display_del_texture (download->display, &download->out_texture[i]);
+      gst_gl_context_del_texture (download->context, &download->out_texture[i]);
       download->out_texture[i] = 0;
     }
   }
+
   if (download->in_texture) {
-    gst_gl_display_del_texture (download->display, &download->in_texture);
+    gst_gl_context_del_texture (download->context, &download->in_texture);
     download->in_texture = 0;
   }
   if (download->fbo || download->depth_buffer) {
-    gst_gl_display_del_fbo (download->display, download->fbo,
+    gst_gl_context_del_fbo (download->context, download->fbo,
         download->depth_buffer);
     download->fbo = 0;
     download->depth_buffer = 0;
@@ -349,9 +350,9 @@ gst_gl_download_finalize (GObject * object)
     download->shader = NULL;
   }
 
-  if (download->display) {
-    gst_object_unref (download->display);
-    download->display = NULL;
+  if (download->context) {
+    gst_object_unref (download->context);
+    download->context = NULL;
   }
 
   g_mutex_clear (&download->lock);
@@ -393,8 +394,8 @@ gst_gl_download_init_format (GstGLDownload * download, GstVideoFormat v_format,
 
   download->info = info;
 
-  gst_gl_display_thread_add (download->display,
-      (GstGLDisplayThreadFunc) _init_download, download);
+  gst_gl_context_thread_add (download->context,
+      (GstGLContextThreadFunc) _init_download, download);
 
   ret = download->initted = download->priv->result;
 
@@ -497,20 +498,20 @@ _gst_gl_download_perform_with_data_unlocked (GstGLDownload * download,
     download->data[i] = data[i];
   }
 
-  gst_gl_display_thread_add (download->display,
-      (GstGLDisplayThreadFunc) _do_download, download);
+  gst_gl_context_thread_add (download->context,
+      (GstGLContextThreadFunc) _do_download, download);
 
   return download->priv->result;
 }
 
 static void
-_init_download (GstGLDisplay * display, GstGLDownload * download)
+_init_download (GstGLContext * context, GstGLDownload * download)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
   guint out_width, out_height;
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
   v_format = GST_VIDEO_INFO_FORMAT (&download->info);
   out_width = GST_VIDEO_INFO_WIDTH (&download->info);
   out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
@@ -518,7 +519,7 @@ _init_download (GstGLDisplay * display, GstGLDownload * download)
   GST_TRACE ("initializing texture download for format %s",
       gst_video_format_to_string (v_format));
 
-  if (USING_OPENGL (display)) {
+  if (USING_OPENGL (context)) {
     switch (v_format) {
       case GST_VIDEO_FORMAT_RGBx:
       case GST_VIDEO_FORMAT_BGRx:
@@ -560,7 +561,7 @@ _init_download (GstGLDisplay * display, GstGLDownload * download)
         /* Frame buffer object is a requirement 
          * when using GLSL colorspace conversion
          */
-        gst_gl_display_set_error (display,
+        gst_gl_context_set_error (context,
             "Context, EXT_framebuffer_object supported: no");
         goto error;
       }
@@ -574,7 +575,7 @@ _init_download (GstGLDisplay * display, GstGLDownload * download)
       gl->GenRenderbuffers (1, &download->depth_buffer);
       gl->BindRenderbuffer (GL_RENDERBUFFER, download->depth_buffer);
 #if GST_GL_HAVE_OPENGL
-      if (USING_OPENGL (display)) {
+      if (USING_OPENGL (context)) {
         gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT,
             out_width, out_height);
         gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
@@ -582,7 +583,7 @@ _init_download (GstGLDisplay * display, GstGLDownload * download)
       }
 #endif
 #if GST_GL_HAVE_GLES2
-      if (USING_GLES2 (display)) {
+      if (USING_GLES2 (context)) {
         gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
             out_width, out_height);
       }
@@ -650,13 +651,13 @@ _init_download (GstGLDisplay * display, GstGLDownload * download)
       /* attach the depth render buffer to the FBO */
       gl->FramebufferRenderbuffer (GL_FRAMEBUFFER,
           GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, download->depth_buffer);
-      if (USING_OPENGL (display)) {
+      if (USING_OPENGL (context)) {
         gl->FramebufferRenderbuffer (GL_FRAMEBUFFER,
             GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, download->depth_buffer);
       }
 
-      if (!gst_gl_display_check_framebuffer_status (display))
-        gst_gl_display_set_error (display, "GL framebuffer status incomplete");
+      if (!gst_gl_context_check_framebuffer_status (context))
+        gst_gl_context_set_error (context, "GL framebuffer status incomplete");
 
       /* unbind the FBO */
       gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
@@ -664,13 +665,13 @@ _init_download (GstGLDisplay * display, GstGLDownload * download)
       break;
     default:
       break;
-      gst_gl_display_set_error (display, "Unsupported download video format %d",
+      gst_gl_context_set_error (context, "Unsupported download video format %d",
           v_format);
       g_assert_not_reached ();
   }
 
 no_convert:
-  download->priv->result = _init_download_shader (display, download);
+  download->priv->result = _init_download_shader (context, download);
   return;
 
 error:
@@ -681,7 +682,7 @@ error:
 }
 
 static gboolean
-_create_shader (GstGLDisplay * display, const gchar * vertex_src,
+_create_shader (GstGLContext * context, const gchar * vertex_src,
     const gchar * fragment_src, GstGLShader ** out_shader)
 {
   GstGLShader *shader;
@@ -689,7 +690,7 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
 
   g_return_val_if_fail (vertex_src != NULL || fragment_src != NULL, FALSE);
 
-  shader = gst_gl_shader_new (display);
+  shader = gst_gl_shader_new (context);
 
   if (vertex_src)
     gst_gl_shader_set_vertex_source (shader, vertex_src);
@@ -697,9 +698,9 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
     gst_gl_shader_set_fragment_source (shader, fragment_src);
 
   if (!gst_gl_shader_compile (shader, &error)) {
-    gst_gl_display_set_error (display, "%s", error->message);
+    gst_gl_context_set_error (context, "%s", error->message);
     g_error_free (error);
-    gst_gl_display_clear_shader (display);
+    gst_gl_context_clear_shader (context);
     gst_object_unref (shader);
     return FALSE;
   }
@@ -709,17 +710,16 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
 }
 
 static gboolean
-_init_download_shader (GstGLDisplay * display, GstGLDownload * download)
+_init_download_shader (GstGLContext * context, GstGLDownload * download)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
 
-  gl = display->gl_vtable;
+  gl = download->context->gl_vtable;
   v_format = GST_VIDEO_INFO_FORMAT (&download->info);
 
-
   if (GST_VIDEO_FORMAT_INFO_IS_RGB (download->info.finfo)
-      && !USING_GLES2 (display)) {
+      && !USING_GLES2 (context)) {
     switch (v_format) {
       case GST_VIDEO_FORMAT_RGBx:
       case GST_VIDEO_FORMAT_BGRx:
@@ -745,7 +745,7 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
    */
   if (!gl->CreateProgramObject && !gl->CreateProgram) {
     /* colorspace conversion is not possible */
-    gst_gl_display_set_error (display,
+    gst_gl_context_set_error (context,
         "Context, ARB_fragment_shader supported: no");
     return FALSE;;
   }
@@ -758,9 +758,9 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
       sprintf (text_shader_download_YUY2,
           download->priv->YUY2_UYVY, "y2,u,y1,v");
 
-      if (_create_shader (display, download->priv->vert_shader,
+      if (_create_shader (context, download->priv->vert_shader,
               text_shader_download_YUY2, &download->shader)) {
-        if (USING_GLES2 (display)) {
+        if (USING_GLES2 (context)) {
           download->shader_attr_position_loc =
               gst_gl_shader_get_attribute_location (download->shader,
               "a_position");
@@ -778,9 +778,9 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
       sprintf (text_shader_download_UYVY,
           download->priv->YUY2_UYVY, "v,y1,u,y2");
 
-      if (_create_shader (display, download->priv->vert_shader,
+      if (_create_shader (context, download->priv->vert_shader,
               text_shader_download_UYVY, &download->shader)) {
-        if (USING_GLES2 (display)) {
+        if (USING_GLES2 (context)) {
           download->shader_attr_position_loc =
               gst_gl_shader_get_attribute_location (download->shader,
               "a_position");
@@ -794,15 +794,15 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
     case GST_VIDEO_FORMAT_I420:
     case GST_VIDEO_FORMAT_YV12:
     {
-      _create_shader (display, download->priv->vert_shader,
+      _create_shader (context, download->priv->vert_shader,
           download->priv->I420_YV12, &download->shader);
       break;
     }
     case GST_VIDEO_FORMAT_AYUV:
     {
-      if (_create_shader (display, download->priv->vert_shader,
+      if (_create_shader (context, download->priv->vert_shader,
               download->priv->AYUV, &download->shader)) {
-        if (USING_GLES2 (display)) {
+        if (USING_GLES2 (context)) {
           download->shader_attr_position_loc =
               gst_gl_shader_get_attribute_location (download->shader,
               "a_position");
@@ -847,7 +847,7 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
           break;
       }
 
-      if (_create_shader (display, download->priv->vert_shader,
+      if (_create_shader (context, download->priv->vert_shader,
               text_shader_ARGB, &download->shader)) {
         download->shader_attr_position_loc =
             gst_gl_shader_get_attribute_location (download->shader,
@@ -864,7 +864,7 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
       break;
 #endif
     default:
-      gst_gl_display_set_error (display,
+      gst_gl_context_set_error (context,
           "Unsupported download video format %d", v_format);
       g_assert_not_reached ();
       return FALSE;
@@ -876,7 +876,7 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
 
 /* Called in the gl thread */
 static void
-_do_download (GstGLDisplay * display, GstGLDownload * download)
+_do_download (GstGLContext * context, GstGLDownload * download)
 {
   GstVideoFormat v_format;
   guint out_width, out_height;
@@ -900,7 +900,7 @@ _do_download (GstGLDisplay * display, GstGLDownload * download)
     case GST_VIDEO_FORMAT_RGB:
     case GST_VIDEO_FORMAT_BGR:
       /* color space conversion is not needed */
-      download->priv->do_rgb (display, download);
+      download->priv->do_rgb (context, download);
       break;
     case GST_VIDEO_FORMAT_YUY2:
     case GST_VIDEO_FORMAT_UYVY:
@@ -908,10 +908,10 @@ _do_download (GstGLDisplay * display, GstGLDownload * download)
     case GST_VIDEO_FORMAT_YV12:
     case GST_VIDEO_FORMAT_AYUV:
       /* color space conversion is needed */
-      download->priv->do_yuv (display, download);
+      download->priv->do_yuv (context, download);
       break;
     default:
-      gst_gl_display_set_error (display, "Unsupported download video format %d",
+      gst_gl_context_set_error (context, "Unsupported download video format %d",
           v_format);
       g_assert_not_reached ();
       break;
@@ -922,14 +922,14 @@ _do_download (GstGLDisplay * display, GstGLDownload * download)
 
 #if GST_GL_HAVE_OPENGL
 static void
-_do_download_draw_rgb_opengl (GstGLDisplay * display, GstGLDownload * download)
+_do_download_draw_rgb_opengl (GstGLContext * context, GstGLDownload * download)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
 
-  gl = display->gl_vtable;
+  gl = download->context->gl_vtable;
 
-  gst_gl_display_clear_shader (display);
+  gst_gl_context_clear_shader (context);
 
   gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
   gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, download->in_texture);
@@ -976,7 +976,7 @@ _do_download_draw_rgb_opengl (GstGLDisplay * display, GstGLDownload * download)
           GL_UNSIGNED_BYTE, download->data[0]);
       break;
     default:
-      gst_gl_display_set_error (display,
+      gst_gl_context_set_error (context,
           "Download video format inconsistency %d", v_format);
       g_assert_not_reached ();
       break;
@@ -989,7 +989,7 @@ _do_download_draw_rgb_opengl (GstGLDisplay * display, GstGLDownload * download)
 
 #if GST_GL_HAVE_GLES2
 static void
-_do_download_draw_rgb_gles2 (GstGLDisplay * display, GstGLDownload * download)
+_do_download_draw_rgb_gles2 (GstGLContext * context, GstGLDownload * download)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
@@ -1009,12 +1009,12 @@ _do_download_draw_rgb_gles2 (GstGLDisplay * display, GstGLDownload * download)
 
   GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
 
-  gl = display->gl_vtable;
+  gl = download->context->gl_vtable;
 
   out_width = GST_VIDEO_INFO_WIDTH (&download->info);
   out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
 
-  gst_gl_display_check_framebuffer_status (display);
+  gst_gl_context_check_framebuffer_status (context);
   gl->BindFramebuffer (GL_FRAMEBUFFER, download->fbo);
 
   gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
@@ -1040,7 +1040,7 @@ _do_download_draw_rgb_gles2 (GstGLDisplay * display, GstGLDownload * download)
 
   gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
 
-  gst_gl_display_clear_shader (display);
+  gst_gl_context_clear_shader (context);
 
   gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
       viewport_dim[3]);
@@ -1065,20 +1065,20 @@ _do_download_draw_rgb_gles2 (GstGLDisplay * display, GstGLDownload * download)
           download->data[0]);
       break;
     default:
-      gst_gl_display_set_error (display,
+      gst_gl_context_set_error (context,
           "Download video format inconsistency %d", v_format);
       g_assert_not_reached ();
       break;
   }
 
-  gst_gl_display_check_framebuffer_status (display);
+  gst_gl_context_check_framebuffer_status (context);
   gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
 }
 #endif
 
 #if GST_GL_HAVE_OPENGL
 static void
-_do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
+_do_download_draw_yuv_opengl (GstGLContext * context, GstGLDownload * download)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
@@ -1102,7 +1102,7 @@ _do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
     out_width, out_height
   };
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   v_format = GST_VIDEO_INFO_FORMAT (&download->info);
 
@@ -1168,7 +1168,7 @@ _do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
 
     default:
       break;
-      gst_gl_display_set_error (display,
+      gst_gl_context_set_error (context,
           "Download video format inconsistensy %d", v_format);
   }
 
@@ -1200,7 +1200,7 @@ _do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
   gl->PopMatrix ();
   gl->PopAttrib ();
 
-  gst_gl_display_check_framebuffer_status (display);
+  gst_gl_context_check_framebuffer_status (context);
 
   gl->BindFramebuffer (GL_FRAMEBUFFER, download->fbo);
   gl->ReadBuffer (GL_COLOR_ATTACHMENT0);
@@ -1263,13 +1263,13 @@ _do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
       break;
     default:
       break;
-      gst_gl_display_set_error (display,
+      gst_gl_context_set_error (context,
           "Download video format inconsistensy %d", v_format);
       g_assert_not_reached ();
   }
   gl->ReadBuffer (GL_NONE);
 
-  gst_gl_display_check_framebuffer_status (display);
+  gst_gl_context_check_framebuffer_status (context);
 
   gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
 }
@@ -1277,7 +1277,7 @@ _do_download_draw_yuv_opengl (GstGLDisplay * display, GstGLDownload * download)
 
 #if GST_GL_HAVE_GLES2
 static void
-_do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
+_do_download_draw_yuv_gles2 (GstGLContext * context, GstGLDownload * download)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
@@ -1297,7 +1297,7 @@ _do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
 
   GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   out_width = GST_VIDEO_INFO_WIDTH (&download->info);
   out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
@@ -1306,7 +1306,7 @@ _do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
   GST_TRACE ("doing YUV download of texture:%u (%ux%u) using fbo:%u",
       download->in_texture, out_width, out_height, download->fbo);
 
-  gst_gl_display_check_framebuffer_status (display);
+  gst_gl_context_check_framebuffer_status (context);
   gl->BindFramebuffer (GL_FRAMEBUFFER, download->fbo);
 
   gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
@@ -1355,7 +1355,7 @@ _do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
 
     default:
       break;
-      gst_gl_display_set_error (display,
+      gst_gl_context_set_error (context,
           "Download video format inconsistensy %d", v_format);
 
   }
@@ -1366,7 +1366,7 @@ _do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
    * because download yuv is not available
    * without GLSL (whereas rgb is)
    */
-  gst_gl_display_clear_shader (display);
+  gst_gl_context_clear_shader (context);
 
   gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
       viewport_dim[3]);
@@ -1421,12 +1421,12 @@ _do_download_draw_yuv_gles2 (GstGLDisplay * display, GstGLDownload * download)
       break;
     default:
       break;
-      gst_gl_display_set_error (display,
+      gst_gl_context_set_error (context,
           "Download video format inconsistensy %d", v_format);
       g_assert_not_reached ();
   }
 
-  gst_gl_display_check_framebuffer_status (display);
+  gst_gl_context_check_framebuffer_status (context);
   gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
 }
 #endif
index 8978591..5696a87 100644 (file)
@@ -51,7 +51,7 @@ struct _GstGLDownload
 
   GMutex           lock;
 
-  GstGLDisplay     *display;
+  GstGLContext     *context;
 
   /* output data */
   GstVideoInfo     info;
@@ -99,7 +99,7 @@ struct _GstGLDownloadClass
  */
 #define GST_GL_DOWNLOAD_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_GL_DOWNLOAD_FORMATS)
 
-GstGLDownload * gst_gl_download_new          (GstGLDisplay * display);
+GstGLDownload * gst_gl_download_new          (GstGLContext * context);
 
 gboolean gst_gl_download_init_format                (GstGLDownload * download, GstVideoFormat v_format,
                                                      guint out_width, guint out_height);
index df6f0fd..15a10f3 100644 (file)
@@ -139,7 +139,7 @@ _gst_gl_feature_check_for_extension (const GstGLFeatureData * data,
 }
 
 gboolean
-_gst_gl_feature_check (GstGLDisplay * display,
+_gst_gl_feature_check (GstGLContext * context,
     const char *driver_prefix,
     const GstGLFeatureData * data,
     int gl_major, int gl_minor, const char *extensions_string)
@@ -148,15 +148,15 @@ _gst_gl_feature_check (GstGLDisplay * display,
   gboolean in_core = FALSE;
   const char *suffix = NULL;
   int func_num;
-  GstGLFuncs *gst_gl = display->gl_vtable;
-  GstGLContext *context = NULL;
+  GstGLFuncs *gst_gl = context->gl_vtable;
+  GstGLAPI gl_api = gst_gl_context_get_gl_api (context);
 
   /* First check whether the functions should be directly provided by
      GL */
-  if (((display->gl_api & GST_GL_API_OPENGL) &&
+  if (((gl_api & GST_GL_API_OPENGL) &&
           GST_GL_CHECK_GL_VERSION (gl_major, gl_minor,
               data->min_gl_major, data->min_gl_minor)) ||
-      ((display->gl_api & GST_GL_API_GLES2) &&
+      ((gl_api & GST_GL_API_GLES2) &&
           (data->gl_availability & GST_GL_API_GLES2))) {
     in_core = TRUE;
     suffix = "";
@@ -172,9 +172,6 @@ _gst_gl_feature_check (GstGLDisplay * display,
   if (suffix == NULL)
     goto error;
 
-  context = gst_gl_display_get_context (display);
-  g_assert (context);
-
   /* Try to get all of the entry points */
   for (func_num = 0; data->functions[func_num].name; func_num++) {
     void *func;
@@ -213,7 +210,6 @@ _gst_gl_feature_check (GstGLDisplay * display,
   }
 
   g_free (full_function_name);
-  gst_object_unref (context);
 
   return TRUE;
 
@@ -232,20 +228,17 @@ error:
     g_free (full_function_name);
   }
 
-  if (context)
-    gst_object_unref (context);
-
   return FALSE;
 }
 
 void
-_gst_gl_feature_check_ext_functions (GstGLDisplay * display,
+_gst_gl_feature_check_ext_functions (GstGLContext * context,
     int gl_major, int gl_minor, const char *gl_extensions)
 {
   int i;
 
   for (i = 0; i < G_N_ELEMENTS (gst_gl_feature_ext_functions_data); i++) {
-    _gst_gl_feature_check (display, "GL",
+    _gst_gl_feature_check (context, "GL",
         gst_gl_feature_ext_functions_data + i, gl_major, gl_minor,
         gl_extensions);
   }
index 1595413..8be732c 100644 (file)
@@ -90,7 +90,7 @@ gboolean
 gst_gl_check_extension (const char *name, const gchar * ext);
 
 gboolean
-_gst_gl_feature_check (GstGLDisplay *display,
+_gst_gl_feature_check (GstGLContext *context,
                      const char *driver_prefix,
                      const GstGLFeatureData *data,
                      int gl_major,
@@ -98,7 +98,7 @@ _gst_gl_feature_check (GstGLDisplay *display,
                      const char *extensions_string);
 
 void
-_gst_gl_feature_check_ext_functions (GstGLDisplay *display,
+_gst_gl_feature_check_ext_functions (GstGLContext *context,
                                    int gl_major,
                                    int gl_minor,
                                    const char *gl_extensions);
index 4428a4b..dd5ee59 100644 (file)
@@ -82,9 +82,9 @@ static gboolean gst_gl_filter_decide_allocation (GstBaseTransform * trans,
 static gboolean gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
     GstCaps * outcaps);
 
-/* GstGLDisplayThreadFunc */
-static void gst_gl_filter_start_gl (GstGLDisplay * display, gpointer data);
-static void gst_gl_filter_stop_gl (GstGLDisplay * display, gpointer data);
+/* GstGLContextThreadFunc */
+static void gst_gl_filter_start_gl (GstGLContext * context, gpointer data);
+static void gst_gl_filter_stop_gl (GstGLContext * context, gpointer data);
 
 static void
 gst_gl_filter_class_init (GstGLFilterClass * klass)
@@ -215,18 +215,23 @@ gst_gl_filter_reset (GstGLFilter * filter)
 {
   GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
 
-  if (filter->display) {
+  if (filter->context) {
     if (filter_class->onReset)
       filter_class->onReset (filter);
 
     if (filter_class->display_reset_cb != NULL) {
-      gst_gl_display_thread_add (filter->display, gst_gl_filter_stop_gl,
+      gst_gl_context_thread_add (filter->context, gst_gl_filter_stop_gl,
           filter);
     }
     //blocking call, delete the FBO
-    gst_gl_display_del_fbo (filter->display, filter->fbo, filter->depthbuffer);
+    gst_gl_context_del_fbo (filter->context, filter->fbo, filter->depthbuffer);
+    gst_object_unref (filter->context);
+    filter->context = NULL;
+  }
+
+  if (filter->display) {
     gst_object_unref (filter->display);
-    filter->display = NULL;
+    filter->context = NULL;
   }
 
   filter->fbo = 0;
@@ -255,21 +260,20 @@ gst_gl_filter_start (GstBaseTransform * bt)
   }
 
   id_value = gst_structure_get_value (structure, "gstgldisplay");
-  if (G_VALUE_HOLDS_POINTER (id_value))
+  if (G_VALUE_HOLDS_POINTER (id_value)) {
     /* at least one gl element is after in our gl chain */
     filter->display =
         gst_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
-  else {
-    GstGLContext *context;
+    filter->context = gst_gl_display_get_context (filter->display);
+  } else {
     GError *error = NULL;
 
     GST_INFO ("Creating GstGLDisplay");
     filter->display = gst_gl_display_new ();
-    context = gst_gl_context_new (filter->display);
-    gst_gl_display_set_context (filter->display, context);
-    gst_object_unref (context);
+    filter->context = gst_gl_context_new (filter->display);
+    gst_gl_display_set_context (filter->display, filter->context);
 
-    if (!gst_gl_context_create (context, filter->other_context, &error)) {
+    if (!gst_gl_context_create (filter->context, filter->other_context, &error)) {
       GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND,
           ("%s", error->message), (NULL));
       return FALSE;
@@ -297,7 +301,7 @@ gst_gl_filter_stop (GstBaseTransform * bt)
 }
 
 static void
-gst_gl_filter_start_gl (GstGLDisplay * display, gpointer data)
+gst_gl_filter_start_gl (GstGLContext * context, gpointer data)
 {
   GstGLFilter *filter = GST_GL_FILTER (data);
   GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
@@ -306,7 +310,7 @@ gst_gl_filter_start_gl (GstGLDisplay * display, gpointer data)
 }
 
 static void
-gst_gl_filter_stop_gl (GstGLDisplay * display, gpointer data)
+gst_gl_filter_stop_gl (GstGLContext * context, gpointer data)
 {
   GstGLFilter *filter = GST_GL_FILTER (data);
   GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
@@ -728,18 +732,18 @@ gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
   out_height = GST_VIDEO_INFO_HEIGHT (&filter->out_info);
 
   //blocking call, generate a FBO
-  if (!gst_gl_display_gen_fbo (filter->display, out_width, out_height,
+  if (!gst_gl_context_gen_fbo (filter->context, out_width, out_height,
           &filter->fbo, &filter->depthbuffer))
     goto display_error;
 
-  gst_gl_display_gen_texture (filter->display, &filter->in_tex_id,
+  gst_gl_context_gen_texture (filter->context, &filter->in_tex_id,
       GST_VIDEO_FORMAT_RGBA, in_width, in_height);
 
-  gst_gl_display_gen_texture (filter->display, &filter->out_tex_id,
+  gst_gl_context_gen_texture (filter->context, &filter->out_tex_id,
       GST_VIDEO_FORMAT_RGBA, out_width, out_height);
 
   if (filter_class->display_init_cb != NULL) {
-    gst_gl_display_thread_add (filter->display, gst_gl_filter_start_gl, filter);
+    gst_gl_context_thread_add (filter->context, gst_gl_filter_start_gl, filter);
   }
 #if 0
   if (!filter->display->isAlive)
@@ -771,7 +775,7 @@ wrong_caps:
 display_error:
   {
     GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND,
-        ("%s", gst_gl_display_get_error ()), (NULL));
+        ("%s", gst_gl_context_get_error ()), (NULL));
     return FALSE;
   }
 
@@ -823,7 +827,7 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
       goto invalid_caps;
 
     GST_DEBUG_OBJECT (filter, "create new pool");
-    pool = gst_gl_buffer_pool_new (filter->display);
+    pool = gst_gl_buffer_pool_new (filter->context);
 
     /* the normal size of a frame */
     size = info.size;
@@ -888,7 +892,7 @@ gst_gl_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query)
   }
 
   if (!pool)
-    pool = gst_gl_buffer_pool_new (filter->display);
+    pool = gst_gl_buffer_pool_new (filter->context);
 
   config = gst_buffer_pool_get_config (pool);
   gst_buffer_pool_config_set_params (config, caps, size, min, max);
@@ -949,7 +953,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
         "attempting to wrap for upload");
 
     if (!filter->upload) {
-      filter->upload = gst_gl_upload_new (filter->display);
+      filter->upload = gst_gl_upload_new (filter->context);
 
       if (!gst_gl_upload_init_format (filter->upload,
               GST_VIDEO_FRAME_FORMAT (&in_frame),
@@ -970,7 +974,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
         "attempting to wrap for download");
 
     if (!filter->download) {
-      filter->download = gst_gl_download_new (filter->display);
+      filter->download = gst_gl_download_new (filter->context);
 
       if (!gst_gl_download_init_format (filter->download,
               GST_VIDEO_FRAME_FORMAT (&out_frame),
@@ -986,7 +990,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
     out_tex = filter->out_tex_id;
   } else {                      /* both non-GL */
     if (!filter->upload) {
-      filter->upload = gst_gl_upload_new (filter->display);
+      filter->upload = gst_gl_upload_new (filter->context);
 
       if (!gst_gl_upload_init_format (filter->upload,
               GST_VIDEO_FRAME_FORMAT (&in_frame),
@@ -1001,7 +1005,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
     }
 
     if (!filter->download) {
-      filter->download = gst_gl_download_new (filter->display);
+      filter->download = gst_gl_download_new (filter->context);
 
       if (!gst_gl_download_init_format (filter->download,
               GST_VIDEO_FRAME_FORMAT (&out_frame),
@@ -1100,7 +1104,7 @@ gst_gl_filter_render_to_target (GstGLFilter * filter, gboolean resize,
   GST_LOG ("rendering to target. in:%ux%u out:%ux%u", in_width, in_height,
       out_width, out_height);
 
-  gst_gl_display_use_fbo (filter->display,
+  gst_gl_context_use_fbo (filter->context,
       out_width, out_height,
       filter->fbo, filter->depthbuffer, target,
       func, in_width, in_height, input, 0,
@@ -1112,7 +1116,7 @@ static void
 _draw_with_shader_cb (gint width, gint height, guint texture, gpointer stuff)
 {
   GstGLFilter *filter = GST_GL_FILTER (stuff);
-  GstGLFuncs *gl = filter->display->gl_vtable;
+  GstGLFuncs *gl = filter->context->gl_vtable;
 
   gl->MatrixMode (GL_PROJECTION);
   gl->LoadIdentity ();
@@ -1149,7 +1153,7 @@ void
 gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
     gboolean resize, GLuint input, GLuint target, GstGLShader * shader)
 {
-  g_return_if_fail (gst_gl_display_get_gl_api (filter->display) &
+  g_return_if_fail (gst_gl_context_get_gl_api (filter->context) &
       GST_GL_API_OPENGL);
 
   filter->default_shader = shader;
@@ -1170,7 +1174,7 @@ void
 gst_gl_filter_draw_texture (GstGLFilter * filter, GLuint texture,
     guint width, guint height)
 {
-  GstGLFuncs *gl = filter->display->gl_vtable;
+  GstGLFuncs *gl = filter->context->gl_vtable;
 
   GLfloat verts[] = { -1.0f, -1.0f,
     1.0f, -1.0f,
index 0147879..c984eaa 100644 (file)
@@ -65,6 +65,7 @@ struct _GstGLFilter
   GstBufferPool     *pool;
 
   GstGLDisplay      *display;
+  GstGLContext      *context;
 
   GstVideoInfo       in_info;
   GstVideoInfo       out_info;
index ae8bb5e..35c2211 100644 (file)
@@ -66,20 +66,20 @@ gst_gl_framebuffer_finalize (GObject * object)
 {
   GstGLFramebuffer *fbo = GST_GL_FRAMEBUFFER (object);
 
-  if (fbo->display) {
-    gst_object_unref (fbo->display);
-    fbo->display = NULL;
+  if (fbo->context) {
+    gst_object_unref (fbo->context);
+    fbo->context = NULL;
   }
 
   G_OBJECT_CLASS (gst_gl_framebuffer_parent_class)->finalize (object);
 }
 
 GstGLFramebuffer *
-gst_gl_framebuffer_new (GstGLDisplay * display)
+gst_gl_framebuffer_new (GstGLContext * context)
 {
   GstGLFramebuffer *fbo = g_object_new (GST_TYPE_GL_FRAMEBUFFER, NULL);
 
-  fbo->display = gst_object_ref (display);
+  fbo->context = gst_object_ref (context);
 
   return fbo;
 }
@@ -95,12 +95,12 @@ gst_gl_framebuffer_generate (GstGLFramebuffer * frame, gint width, gint height,
   g_return_val_if_fail (fbo != NULL && depth != NULL, FALSE);
   g_return_val_if_fail (width > 0 && height > 0, FALSE);
 
-  gl = gst_gl_display_get_gl_vtable (frame->display);
+  gl = frame->context->gl_vtable;
 
   GST_TRACE ("creating FBO dimensions:%ux%u", width, height);
 
   if (!gl->GenFramebuffers) {
-    gst_gl_display_set_error (frame->display,
+    gst_gl_context_set_error (frame->context,
         "Context, EXT_framebuffer_object not supported");
     return FALSE;
   }
@@ -112,13 +112,13 @@ gst_gl_framebuffer_generate (GstGLFramebuffer * frame, gint width, gint height,
   gl->GenRenderbuffers (1, depth);
   gl->BindRenderbuffer (GL_RENDERBUFFER, *depth);
 
-  if (gst_gl_display_get_gl_api (frame->display) & GST_GL_API_OPENGL) {
+  if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_OPENGL) {
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT,
         width, height);
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
         width, height);
   }
-  if (gst_gl_display_get_gl_api (frame->display) & GST_GL_API_GLES2) {
+  if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_GLES2) {
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
         width, height);
   }
@@ -145,13 +145,13 @@ gst_gl_framebuffer_generate (GstGLFramebuffer * frame, gint width, gint height,
   gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
       GL_RENDERBUFFER, *depth);
 
-  if (gst_gl_display_get_gl_api (frame->display) & GST_GL_API_OPENGL) {
+  if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_OPENGL) {
     gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
         GL_RENDERBUFFER, *depth);
   }
 
   if (gl->CheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
-    gst_gl_display_set_error (frame->display,
+    gst_gl_context_set_error (frame->context,
         "GL framebuffer status incomplete");
     return FALSE;
   }
@@ -185,7 +185,7 @@ gst_gl_framebuffer_use (GstGLFramebuffer * frame, gint texture_fbo_width,
   g_return_val_if_fail (texture_fbo != 0, FALSE);
   g_return_val_if_fail (cb != NULL, FALSE);
 
-  gl = frame->display->gl_vtable;
+  gl = frame->context->gl_vtable;
 
   GST_TRACE ("Binding v1 FBO %u dimensions:%ux%u with texture:%u "
       "dimensions:%ux%u", fbo, texture_fbo_width,
@@ -200,10 +200,10 @@ gst_gl_framebuffer_use (GstGLFramebuffer * frame, gint texture_fbo_width,
   gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
       GL_TEXTURE_RECTANGLE_ARB, texture_fbo, 0);
 
-  gst_gl_display_clear_shader (frame->display);
+  gst_gl_context_clear_shader (frame->context);
 
 #if GST_GL_HAVE_OPENGL
-  if (gst_gl_display_get_gl_api (frame->display) & GST_GL_API_OPENGL) {
+  if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_OPENGL) {
     gl->PushAttrib (GL_VIEWPORT_BIT);
     gl->MatrixMode (GL_PROJECTION);
     gl->PushMatrix ();
@@ -217,7 +217,7 @@ gst_gl_framebuffer_use (GstGLFramebuffer * frame, gint texture_fbo_width,
         gluPerspective (proj_param1, proj_param2, proj_param3, proj_param4);
         break;
       default:
-        gst_gl_display_set_error (frame->display, "Unknow fbo projection %d",
+        gst_gl_context_set_error (frame->context, "Unknow fbo projection %d",
             projection);
     }
 
@@ -227,14 +227,14 @@ gst_gl_framebuffer_use (GstGLFramebuffer * frame, gint texture_fbo_width,
   }
 #endif
 #if GST_GL_HAVE_GLES2
-  if (gst_gl_display_get_gl_api (frame->display) & GST_GL_API_GLES2)
+  if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_GLES2)
     gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
 #endif
 
   gl->Viewport (0, 0, texture_fbo_width, texture_fbo_height);
 
 #if GST_GL_HAVE_OPENGL
-  if (gst_gl_display_get_gl_api (frame->display) & GST_GL_API_OPENGL) {
+  if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_OPENGL) {
     const GLenum rt[] = { GL_COLOR_ATTACHMENT0 };
     gl->DrawBuffers (1, rt);
   }
@@ -246,7 +246,7 @@ gst_gl_framebuffer_use (GstGLFramebuffer * frame, gint texture_fbo_width,
   cb (input_tex_width, input_tex_height, input_tex, stuff);
 
 #if GST_GL_HAVE_OPENGL
-  if (gst_gl_display_get_gl_api (frame->display) & GST_GL_API_OPENGL) {
+  if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_OPENGL) {
     const GLenum rt[] = { GL_NONE };
     gl->DrawBuffers (1, rt);
     gl->MatrixMode (GL_PROJECTION);
@@ -257,7 +257,7 @@ gst_gl_framebuffer_use (GstGLFramebuffer * frame, gint texture_fbo_width,
   }
 #endif
 #if GST_GL_HAVE_GLES2
-  if (gst_gl_display_get_gl_api (frame->display) & GST_GL_API_GLES2) {
+  if (gst_gl_context_get_gl_api (frame->context) & GST_GL_API_GLES2) {
     gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
         viewport_dim[3]);
   }
@@ -282,7 +282,7 @@ gst_gl_framebuffer_use_v2 (GstGLFramebuffer * frame, gint texture_fbo_width,
   g_return_val_if_fail (texture_fbo != 0, FALSE);
   g_return_val_if_fail (cb != NULL, FALSE);
 
-  gl = frame->display->gl_vtable;
+  gl = frame->context->gl_vtable;
 
   GST_TRACE ("Binding v2 FBO %u dimensions:%ux%u with texture:%u ",
       fbo, texture_fbo_width, texture_fbo_height, texture_fbo);
@@ -325,7 +325,7 @@ gst_gl_framebuffer_delete (GstGLFramebuffer * frame, guint fbo, guint depth)
 
   g_return_if_fail (GST_IS_GL_FRAMEBUFFER (frame));
 
-  gl = frame->display->gl_vtable;
+  gl = frame->context->gl_vtable;
 
   GST_TRACE ("Deleting FBO %u", fbo);
 
index 6d03692..7f1f261 100644 (file)
@@ -43,7 +43,7 @@ struct _GstGLFramebuffer
   GObject             object;
 
   /* <private> */
-  GstGLDisplay *display;
+  GstGLContext *context;
 
   GstGLFramebufferPrivate  *priv;
 };
@@ -53,7 +53,7 @@ struct _GstGLFramebufferClass
   GObjectClass object_class;
 };
 
-GstGLFramebuffer *gst_gl_framebuffer_new (GstGLDisplay *display);
+GstGLFramebuffer *gst_gl_framebuffer_new (GstGLContext *context);
 
 gboolean gst_gl_framebuffer_generate (GstGLFramebuffer *frame, gint width, gint height,
     guint * fbo, guint * depthbuffer);
index 6108ca7..3578db9 100644 (file)
  * Data is uploaded or downloaded from the GPU as is necessary.
  */
 
-#define USING_OPENGL(display) (display->gl_api & GST_GL_API_OPENGL)
-#define USING_OPENGL3(display) (display->gl_api & GST_GL_API_OPENGL3)
-#define USING_GLES(display) (display->gl_api & GST_GL_API_GLES)
-#define USING_GLES2(display) (display->gl_api & GST_GL_API_GLES2)
-#define USING_GLES3(display) (display->gl_api & GST_GL_API_GLES3)
+#define USING_OPENGL(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL)
+#define USING_OPENGL3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL3)
+#define USING_GLES(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES)
+#define USING_GLES2(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2)
+#define USING_GLES3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES3)
 
 GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_MEMORY);
 #define GST_CAT_DEFUALT GST_CAT_GL_MEMORY
@@ -61,7 +61,7 @@ typedef struct
 
 static void
 _gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
-    GstGLDisplay * display, GstVideoFormat v_format, gsize width, gsize height,
+    GstGLContext * context, GstVideoFormat v_format, gsize width, gsize height,
     gpointer user_data, GDestroyNotify notify)
 {
   gsize maxsize;
@@ -74,7 +74,7 @@ _gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
   gst_memory_init (GST_MEMORY_CAST (mem), GST_MEMORY_FLAG_NO_SHARE,
       allocator, parent, maxsize, 0, 0, maxsize);
 
-  mem->display = gst_object_ref (display);
+  mem->context = gst_object_ref (context);
   mem->gl_format = GL_RGBA;
   mem->v_format = v_format;
   mem->width = width;
@@ -82,8 +82,8 @@ _gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
   mem->notify = notify;
   mem->user_data = user_data;
   mem->wrapped = FALSE;
-  mem->upload = gst_gl_upload_new (display);
-  mem->download = gst_gl_download_new (display);
+  mem->upload = gst_gl_upload_new (context);
+  mem->download = gst_gl_download_new (context);
 
   GST_CAT_DEBUG (GST_CAT_GL_MEMORY,
       "new GL texture memory:%p format:%u dimensions:%" G_GSIZE_FORMAT
@@ -92,22 +92,22 @@ _gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
 
 static GstGLMemory *
 _gl_mem_new (GstAllocator * allocator, GstMemory * parent,
-    GstGLDisplay * display, GstVideoFormat v_format, gsize width, gsize height,
+    GstGLContext * context, GstVideoFormat v_format, gsize width, gsize height,
     gpointer user_data, GDestroyNotify notify)
 {
   GstGLMemory *mem;
   GLuint tex_id;
 
-  gst_gl_display_gen_texture (display, &tex_id, v_format, width, height);
+  gst_gl_context_gen_texture (context, &tex_id, v_format, width, height);
   if (!tex_id) {
     GST_CAT_WARNING (GST_CAT_GL_MEMORY,
-        "Could not create GL texture with display:%p", display);
+        "Could not create GL texture with context:%p", context);
   }
 
   GST_CAT_TRACE (GST_CAT_GL_MEMORY, "created texture %u", tex_id);
 
   mem = g_slice_alloc (sizeof (GstGLMemory));
-  _gl_mem_init (mem, allocator, parent, display, v_format, width, height,
+  _gl_mem_init (mem, allocator, parent, context, v_format, width, height,
       user_data, notify);
 
   mem->tex_id = tex_id;
@@ -199,7 +199,7 @@ _gl_mem_unmap (GstGLMemory * gl_mem)
 }
 
 void
-_gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
+_gl_mem_copy_thread (GstGLContext * context, gpointer data)
 {
   GstGLMemoryCopyParams *copy_params;
   GstGLMemory *src;
@@ -208,7 +208,7 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
   gsize width, height;
   GLuint gl_format;
   GstVideoFormat v_format;
-  GstGLFuncs *gl = display->gl_vtable;
+  GstGLFuncs *gl;
 
   copy_params = (GstGLMemoryCopyParams *) data;
   src = copy_params->src;
@@ -217,17 +217,19 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
   v_format = src->v_format;
   gl_format = src->gl_format;
 
+  gl = src->context->gl_vtable;
+
   if (!gl->GenFramebuffers) {
-    gst_gl_display_set_error (display,
+    gst_gl_context_set_error (src->context,
         "Context, EXT_framebuffer_object not supported");
-    return;
+    goto error;
   }
 
-  gst_gl_display_gen_texture_thread (src->display, &tex_id, v_format, width,
+  gst_gl_context_gen_texture_thread (src->context, &tex_id, v_format, width,
       height);
   if (!tex_id) {
     GST_CAT_WARNING (GST_CAT_GL_MEMORY,
-        "Could not create GL texture with display:%p", src->display);
+        "Could not create GL texture with context:%p", src->context);
   }
 
   GST_CAT_DEBUG (GST_CAT_GL_MEMORY, "created texture %i", tex_id);
@@ -240,13 +242,13 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
   gl->GenRenderbuffers (1, &rboId);
   gl->BindRenderbuffer (GL_RENDERBUFFER, rboId);
 
-  if (USING_OPENGL (display)) {
+  if (USING_OPENGL (src->context)) {
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width,
         height);
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
         width, height);
   }
-  if (USING_GLES2 (display)) {
+  if (USING_GLES2 (src->context)) {
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
         width, height);
   }
@@ -254,7 +256,7 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
   gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
       GL_RENDERBUFFER, rboId);
 
-  if (USING_OPENGL (display)) {
+  if (USING_OPENGL (src->context)) {
     gl->FramebufferRenderbuffer (GL_FRAMEBUFFER,
         GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rboId);
   }
@@ -263,7 +265,7 @@ _gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
       GL_TEXTURE_RECTANGLE_ARB, src->tex_id, 0);
 
   /* check FBO status */
-  if (!gst_gl_display_check_framebuffer_status (display))
+  if (!gst_gl_context_check_framebuffer_status (src->context))
     goto fbo_error;
 
   /* copy tex */
@@ -288,6 +290,13 @@ fbo_error:
     gl->DeleteFramebuffers (1, &fboId);
 
     copy_params->tex_id = 0;
+
+    return;
+  }
+
+error:
+  {
+    return;
   }
 }
 
@@ -298,7 +307,7 @@ _gl_mem_copy (GstGLMemory * src, gssize offset, gssize size)
   GstGLMemoryCopyParams copy_params;
 
   if (GST_GL_MEMORY_FLAG_IS_SET (src, GST_GL_MEMORY_FLAG_NEED_UPLOAD)) {
-    dest = _gl_mem_new (src->mem.allocator, NULL, src->display, src->v_format,
+    dest = _gl_mem_new (src->mem.allocator, NULL, src->context, src->v_format,
         src->width, src->height, NULL, NULL);
     dest->data = g_malloc (src->mem.maxsize);
     memcpy (dest->data, src->data, src->mem.maxsize);
@@ -307,10 +316,10 @@ _gl_mem_copy (GstGLMemory * src, gssize offset, gssize size)
     copy_params = (GstGLMemoryCopyParams) {
     src, 0,};
 
-    gst_gl_display_thread_add (src->display, _gl_mem_copy_thread, &copy_params);
+    gst_gl_context_thread_add (src->context, _gl_mem_copy_thread, &copy_params);
 
     dest = g_slice_alloc (sizeof (GstGLMemory));
-    _gl_mem_init (dest, src->mem.allocator, NULL, src->display, src->v_format,
+    _gl_mem_init (dest, src->mem.allocator, NULL, src->context, src->v_format,
         src->width, src->height, NULL, NULL);
 
     if (!copy_params.tex_id)
@@ -360,11 +369,11 @@ _gl_mem_free (GstAllocator * allocator, GstMemory * mem)
   GstGLMemory *gl_mem = (GstGLMemory *) mem;
 
   if (gl_mem->tex_id)
-    gst_gl_display_del_texture (gl_mem->display, &gl_mem->tex_id);
+    gst_gl_context_del_texture (gl_mem->context, &gl_mem->tex_id);
 
   gst_object_unref (gl_mem->upload);
   gst_object_unref (gl_mem->download);
-  gst_object_unref (gl_mem->display);
+  gst_object_unref (gl_mem->context);
 
   if (gl_mem->notify)
     gl_mem->notify (gl_mem->user_data);
@@ -379,21 +388,21 @@ _gl_mem_free (GstAllocator * allocator, GstMemory * mem)
 
 /**
  * gst_gl_memory_alloc:
- * @display:a #GstGLDisplay
+ * @context:a #GstGLContext
  * @format: the format for the texture
  * @width: width of the texture
  * @height: height of the texture
  *
  * Returns: a #GstMemory object with a GL texture specified by @format, @width and @height
- *          from @display
+ *          from @context
  */
 GstMemory *
-gst_gl_memory_alloc (GstGLDisplay * display, GstVideoFormat format,
+gst_gl_memory_alloc (GstGLContext * context, GstVideoFormat format,
     gsize width, gsize height)
 {
   GstGLMemory *mem;
 
-  mem = _gl_mem_new (_gl_allocator, NULL, display, format, width, height,
+  mem = _gl_mem_new (_gl_allocator, NULL, context, format, width, height,
       NULL, NULL);
 
   mem->data = g_malloc (mem->mem.maxsize);
@@ -407,7 +416,7 @@ gst_gl_memory_alloc (GstGLDisplay * display, GstVideoFormat format,
 
 /**
  * gst_gl_memory_wrapped
- * @display:a #GstGLDisplay
+ * @context:a #GstGLContext
  * @format: the format for the texture
  * @width: width of the texture
  * @height: height of the texture
@@ -416,16 +425,16 @@ gst_gl_memory_alloc (GstGLDisplay * display, GstVideoFormat format,
  * @notify: function called with @user_data when @data needs to be freed
  * 
  * Returns: a #GstGLMemory object with a GL texture specified by @format, @width and @height
- *          from @display and contents specified by @data
+ *          from @context and contents specified by @data
  */
 GstGLMemory *
-gst_gl_memory_wrapped (GstGLDisplay * display, GstVideoFormat format,
+gst_gl_memory_wrapped (GstGLContext * context, GstVideoFormat format,
     guint width, guint height, gpointer data,
     gpointer user_data, GDestroyNotify notify)
 {
   GstGLMemory *mem;
 
-  mem = _gl_mem_new (_gl_allocator, NULL, display, format, width, height,
+  mem = _gl_mem_new (_gl_allocator, NULL, context, format, width, height,
       user_data, notify);
 
   mem->data = data;
index 45b3dd3..fd73e50 100644 (file)
@@ -82,7 +82,7 @@ struct _GstGLMemory
 {
   GstMemory          mem;
 
-  GstGLDisplay      *display;
+  GstGLContext      *context;
   GLuint             tex_id;
   GstVideoFormat     v_format;
   GLenum             gl_format;
@@ -145,10 +145,10 @@ struct _GstGLMemory
 
 void gst_gl_memory_init (void);
 
-GstMemory * gst_gl_memory_alloc (GstGLDisplay * display, GstVideoFormat format,
+GstMemory * gst_gl_memory_alloc (GstGLContext * context, GstVideoFormat format,
                                  gsize width, gsize height);
 
-GstGLMemory * gst_gl_memory_wrapped (GstGLDisplay * display, GstVideoFormat format,
+GstGLMemory * gst_gl_memory_wrapped (GstGLContext * context, GstVideoFormat format,
                                      guint width, guint height, gpointer data,
                                      gpointer user_data, GDestroyNotify notify);
 
index 53a3c2c..7b6f7d3 100644 (file)
@@ -931,20 +931,19 @@ gst_gl_mixer_activate (GstGLMixer * mix, gboolean activate)
     }
 
     id_value = gst_structure_get_value (structure, "gstgldisplay");
-    if (G_VALUE_HOLDS_POINTER (id_value))
+    if (G_VALUE_HOLDS_POINTER (id_value)) {
       mix->display =
           gst_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
-    else {
-      GstGLContext *context;
+      mix->context = gst_gl_display_get_context (mix->display);
+    } else {
       GError *error = NULL;
 
       GST_INFO ("Creating GstGLDisplay");
       mix->display = gst_gl_display_new ();
-      context = gst_gl_context_new (mix->display);
-      gst_gl_display_set_context (mix->display, context);
-      gst_object_unref (context);
+      mix->context = gst_gl_context_new (mix->display);
+      gst_gl_display_set_context (mix->display, mix->context);
 
-      if (!gst_gl_context_create (context, 0, &error)) {
+      if (!gst_gl_context_create (mix->context, 0, &error)) {
         GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND,
             ("%s", error->message), (NULL));
         return FALSE;
@@ -981,7 +980,7 @@ gst_gl_mixer_decide_allocation (GstGLMixer * mix, GstQuery * query)
   }
 
   if (!pool)
-    pool = gst_gl_buffer_pool_new (mix->display);
+    pool = gst_gl_buffer_pool_new (mix->context);
 
   config = gst_buffer_pool_get_config (pool);
   gst_buffer_pool_config_set_params (config, caps, size, min, max);
@@ -1127,13 +1126,13 @@ gst_gl_mixer_src_setcaps (GstPad * pad, GstGLMixer * mix, GstCaps * caps)
   out_width = GST_VIDEO_INFO_WIDTH (&mix->out_info);
   out_height = GST_VIDEO_INFO_HEIGHT (&mix->out_info);
 
-  if (!gst_gl_display_gen_fbo (mix->display, out_width, out_height,
+  if (!gst_gl_context_gen_fbo (mix->context, out_width, out_height,
           &mix->fbo, &mix->depthbuffer))
-    goto display_error;
+    goto context_error;
 
   if (mix->out_tex_id)
-    gst_gl_display_del_texture (mix->display, &mix->out_tex_id);
-  gst_gl_display_gen_texture (mix->display, &mix->out_tex_id,
+    gst_gl_context_del_texture (mix->context, &mix->out_tex_id);
+  gst_gl_context_gen_texture (mix->context, &mix->out_tex_id,
       GST_VIDEO_FORMAT_RGBA, out_width, out_height);
 
   GST_GL_MIXER_UNLOCK (mix);
@@ -1151,10 +1150,10 @@ done:
   return ret;
 
 /* ERRORS */
-display_error:
+context_error:
   {
     GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND,
-        ("%s", gst_gl_display_get_error ()), (NULL));
+        ("%s", gst_gl_context_get_error ()), (NULL));
     return FALSE;
   }
 }
@@ -1450,7 +1449,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
     out_tex = mix->out_tex_id;;
 
     if (!mix->download) {
-      mix->download = gst_gl_download_new (mix->display);
+      mix->download = gst_gl_download_new (mix->context);
       if (!gst_gl_download_init_format (mix->download,
               GST_VIDEO_FRAME_FORMAT (&out_frame),
               GST_VIDEO_FRAME_WIDTH (&out_frame),
@@ -1512,7 +1511,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
         out_height = GST_VIDEO_INFO_HEIGHT (&mix->out_info);
 
         if (!pad->upload) {
-          pad->upload = gst_gl_upload_new (mix->display);
+          pad->upload = gst_gl_upload_new (mix->context);
 
           if (!gst_gl_upload_init_format (pad->upload, in_format,
                   in_width, in_height, in_width, in_height)) {
@@ -1522,7 +1521,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
           }
 
           if (!pad->in_tex_id)
-            gst_gl_display_gen_texture (mix->display, &pad->in_tex_id,
+            gst_gl_context_gen_texture (mix->context, &pad->in_tex_id,
                 GST_VIDEO_FORMAT_RGBA, out_width, out_height);
         }
 
@@ -2152,7 +2151,7 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
       if (mixer_class->reset)
         mixer_class->reset (mix);
       if (mix->fbo) {
-        gst_gl_display_del_fbo (mix->display, mix->fbo, mix->depthbuffer);
+        gst_gl_context_del_fbo (mix->context, mix->fbo, mix->depthbuffer);
         mix->fbo = 0;
         mix->depthbuffer = 0;
       }
@@ -2176,6 +2175,11 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
         gst_object_unref (mix->display);
         mix->display = NULL;
       }
+
+      if (mix->context) {
+        gst_object_unref (mix->context);
+        mix->context = NULL;
+      }
       break;
     }
     default:
index 7d8709f..92fb00c 100644 (file)
@@ -93,6 +93,7 @@ struct _GstGLMixer
   guint64 qos_processed, qos_dropped;
 
   GstGLDisplay *display;
+  GstGLContext *context;
   GLuint fbo;
   GLuint depthbuffer;
 };
index a3d7cf5..9bf7d59 100644 (file)
 #define GST_GL_SHADER_GET_PRIVATE(o)                                   \
   (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_SHADER, GstGLShaderPrivate))
 
-#define USING_OPENGL(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL)
-#define USING_OPENGL3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL3)
-#define USING_GLES(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES)
-#define USING_GLES2(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES2)
-#define USING_GLES3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES3)
+#define USING_OPENGL(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL)
+#define USING_OPENGL3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL3)
+#define USING_GLES(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES)
+#define USING_GLES2(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2)
+#define USING_GLES3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES3)
 
 typedef struct _GstGLShaderVTable
 {
@@ -94,7 +94,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_gl_shader_debug);
 G_DEFINE_TYPE_WITH_CODE (GstGLShader, gst_gl_shader, G_TYPE_OBJECT, DEBUG_INIT);
 
 static void
-_cleanup_shader (GstGLDisplay * display, GstGLShader * shader)
+_cleanup_shader (GstGLContext * context, GstGLShader * shader)
 {
   GstGLShaderPrivate *priv = shader->priv;
 
@@ -129,16 +129,16 @@ gst_gl_shader_finalize (GObject * object)
   g_free (priv->vertex_src);
   g_free (priv->fragment_src);
 
-  gst_gl_display_thread_add (shader->display,
-      (GstGLDisplayThreadFunc) _cleanup_shader, shader);
+  gst_gl_context_thread_add (shader->context,
+      (GstGLContextThreadFunc) _cleanup_shader, shader);
 
   priv->fragment_handle = 0;
   priv->vertex_handle = 0;
   priv->program_handle = 0;
 
-  if (shader->display) {
-    gst_object_unref (shader->display);
-    shader->display = NULL;
+  if (shader->context) {
+    gst_object_unref (shader->context);
+    shader->context = NULL;
   }
 
   G_OBJECT_CLASS (gst_gl_shader_parent_class)->finalize (object);
@@ -295,9 +295,9 @@ gst_gl_shader_init (GstGLShader * self)
 }
 
 gboolean
-_fill_vtable (GstGLShader * shader, GstGLDisplay * display)
+_fill_vtable (GstGLShader * shader, GstGLContext * context)
 {
-  GstGLFuncs *gl = display->gl_vtable;
+  GstGLFuncs *gl = context->gl_vtable;
   GstGLShaderVTable *vtable = &shader->priv->vtable;
 
   if (gl->CreateProgram) {
@@ -340,14 +340,14 @@ _fill_vtable (GstGLShader * shader, GstGLDisplay * display)
 }
 
 GstGLShader *
-gst_gl_shader_new (GstGLDisplay * display)
+gst_gl_shader_new (GstGLContext * context)
 {
   GstGLShader *shader;
 
-  g_return_val_if_fail (GST_IS_GL_DISPLAY (display), NULL);
+  g_return_val_if_fail (GST_GL_IS_CONTEXT (context), NULL);
 
   shader = g_object_new (GST_GL_TYPE_SHADER, NULL);
-  shader->display = gst_object_ref (display);
+  shader->context = gst_object_ref (context);
 
   return shader;
 }
@@ -373,12 +373,12 @@ gst_gl_shader_compile (GstGLShader * shader, GError ** error)
   g_return_val_if_fail (GST_GL_IS_SHADER (shader), FALSE);
 
   priv = shader->priv;
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   if (priv->compiled)
     return priv->compiled;
 
-  if (!_fill_vtable (shader, shader->display))
+  if (!_fill_vtable (shader, shader->context))
     return FALSE;
 
   shader->priv->program_handle = shader->priv->vtable.CreateProgram ();
@@ -526,13 +526,13 @@ gst_gl_shader_use (GstGLShader * shader)
 }
 
 void
-gst_gl_display_clear_shader (GstGLDisplay * display)
+gst_gl_context_clear_shader (GstGLContext * context)
 {
   GstGLFuncs *gl;
 
-  g_return_if_fail (GST_IS_GL_DISPLAY (display));
+  g_return_if_fail (GST_GL_IS_CONTEXT (context));
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   if (gl->CreateProgram)
     gl->UseProgram (0);
@@ -565,10 +565,10 @@ gst_gl_shader_compile_and_check (GstGLShader * shader,
 
     gst_gl_shader_compile (shader, &error);
     if (error) {
-      gst_gl_display_set_error (shader->display, "%s", error->message);
+      gst_gl_context_set_error (shader->context, "%s", error->message);
       g_error_free (error);
-      error = NULL;
-      gst_gl_display_clear_shader (shader->display);
+      gst_gl_context_clear_shader (shader->context);
+
       return FALSE;
     }
   }
@@ -587,7 +587,7 @@ gst_gl_shader_set_uniform_1f (GstGLShader * shader, const gchar * name,
 
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -605,7 +605,7 @@ gst_gl_shader_set_uniform_1fv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -623,7 +623,7 @@ gst_gl_shader_set_uniform_1i (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -641,7 +641,7 @@ gst_gl_shader_set_uniform_1iv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -659,7 +659,7 @@ gst_gl_shader_set_uniform_2f (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -677,7 +677,7 @@ gst_gl_shader_set_uniform_2fv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -695,7 +695,7 @@ gst_gl_shader_set_uniform_2i (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -713,7 +713,7 @@ gst_gl_shader_set_uniform_2iv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -731,7 +731,7 @@ gst_gl_shader_set_uniform_3f (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -749,7 +749,7 @@ gst_gl_shader_set_uniform_3fv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -767,7 +767,7 @@ gst_gl_shader_set_uniform_3i (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -785,7 +785,7 @@ gst_gl_shader_set_uniform_3iv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -803,7 +803,7 @@ gst_gl_shader_set_uniform_4f (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -821,7 +821,7 @@ gst_gl_shader_set_uniform_4fv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -839,7 +839,7 @@ gst_gl_shader_set_uniform_4i (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -857,7 +857,7 @@ gst_gl_shader_set_uniform_4iv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -875,7 +875,7 @@ gst_gl_shader_set_uniform_matrix_2fv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -893,7 +893,7 @@ gst_gl_shader_set_uniform_matrix_3fv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -911,7 +911,7 @@ gst_gl_shader_set_uniform_matrix_4fv (GstGLShader * shader, const gchar * name,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -930,7 +930,7 @@ gst_gl_shader_set_uniform_matrix_2x3fv (GstGLShader * shader,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -948,7 +948,7 @@ gst_gl_shader_set_uniform_matrix_2x4fv (GstGLShader * shader,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -966,7 +966,7 @@ gst_gl_shader_set_uniform_matrix_3x2fv (GstGLShader * shader,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -984,7 +984,7 @@ gst_gl_shader_set_uniform_matrix_3x4fv (GstGLShader * shader,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -1002,7 +1002,7 @@ gst_gl_shader_set_uniform_matrix_4x2fv (GstGLShader * shader,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -1020,7 +1020,7 @@ gst_gl_shader_set_uniform_matrix_4x3fv (GstGLShader * shader,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   location = gl->GetUniformLocation (priv->program_handle, name);
 
@@ -1037,7 +1037,7 @@ gst_gl_shader_get_attribute_location (GstGLShader * shader, const gchar * name)
   g_return_val_if_fail (shader != NULL, 0);
   priv = shader->priv;
   g_return_val_if_fail (priv->program_handle != 0, 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   return gl->GetAttribLocation (priv->program_handle, name);
 }
@@ -1052,7 +1052,7 @@ gst_gl_shader_bind_attribute_location (GstGLShader * shader, GLuint index,
   g_return_if_fail (shader != NULL);
   priv = shader->priv;
   g_return_if_fail (priv->program_handle != 0);
-  gl = shader->display->gl_vtable;
+  gl = shader->context->gl_vtable;
 
   gl->BindAttribLocation (priv->program_handle, index, name);
 }
index aa0e12f..d63ceaa 100644 (file)
@@ -49,7 +49,7 @@ struct _GstGLShader {
   /*< private >*/
   GObject parent;
 
-  GstGLDisplay *display;
+  GstGLContext *context;
 
   GstGLShaderPrivate *priv;
 };
@@ -64,7 +64,7 @@ struct _GstGLShaderClass {
 GQuark gst_gl_shader_error_quark (void);
 GType gst_gl_shader_get_type (void);
 
-GstGLShader * gst_gl_shader_new (GstGLDisplay *display);
+GstGLShader * gst_gl_shader_new (GstGLContext *context);
 
 void          gst_gl_shader_set_vertex_source   (GstGLShader *shader, const gchar *src);
 void          gst_gl_shader_set_fragment_source (GstGLShader *shader, const gchar *src);
@@ -78,7 +78,7 @@ gboolean gst_gl_shader_compile_and_check (GstGLShader *shader, const gchar *sour
 
 void gst_gl_shader_release       (GstGLShader *shader);
 void gst_gl_shader_use           (GstGLShader *shader);
-void gst_gl_display_clear_shader (GstGLDisplay *display);
+void gst_gl_context_clear_shader (GstGLContext *context);
 
 void gst_gl_shader_set_uniform_1i           (GstGLShader *shader, const gchar *name, gint value);
 void gst_gl_shader_set_uniform_1iv          (GstGLShader *shader, const gchar *name, guint count, gint *value);
index bf41f23..a920280 100644 (file)
  * A #GstGLUpload can be created with gst_gl_upload_new()
  */
 
-#define USING_OPENGL(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL)
-#define USING_OPENGL3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL3)
-#define USING_GLES(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES)
-#define USING_GLES2(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES2)
-#define USING_GLES3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES3)
-
-static void _do_upload (GstGLDisplay * display, GstGLUpload * upload);
-static gboolean _do_upload_fill (GstGLDisplay * display, GstGLUpload * upload);
-static gboolean _do_upload_make (GstGLDisplay * display, GstGLUpload * upload);
-static void _init_upload (GstGLDisplay * display, GstGLUpload * upload);
-static gboolean _init_upload_fbo (GstGLDisplay * display, GstGLUpload * upload);
+#define USING_OPENGL(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL)
+#define USING_OPENGL3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL3)
+#define USING_GLES(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES)
+#define USING_GLES2(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2)
+#define USING_GLES3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES3)
+
+static void _do_upload (GstGLContext * context, GstGLUpload * upload);
+static gboolean _do_upload_fill (GstGLContext * context, GstGLUpload * upload);
+static gboolean _do_upload_make (GstGLContext * context, GstGLUpload * upload);
+static void _init_upload (GstGLContext * context, GstGLUpload * upload);
+static gboolean _init_upload_fbo (GstGLContext * context, GstGLUpload * upload);
 static gboolean _gst_gl_upload_perform_with_data_unlocked (GstGLUpload * upload,
     GLuint texture_id, gpointer data[GST_VIDEO_MAX_PLANES]);
 
 #if GST_GL_HAVE_OPENGL
-static gboolean _do_upload_draw_opengl (GstGLDisplay * display,
+static gboolean _do_upload_draw_opengl (GstGLContext * context,
     GstGLUpload * upload);
 #endif
 #if GST_GL_HAVE_GLES2
-static gboolean _do_upload_draw_gles2 (GstGLDisplay * display,
+static gboolean _do_upload_draw_gles2 (GstGLContext * context,
     GstGLUpload * upload);
 #endif
 
@@ -329,7 +329,7 @@ struct _GstGLUploadPrivate
   const gchar *COPY;
   const gchar *vert_shader;
 
-    gboolean (*draw) (GstGLDisplay * display, GstGLUpload * download);
+    gboolean (*draw) (GstGLContext * context, GstGLUpload * download);
 };
 
 GST_DEBUG_CATEGORY_STATIC (gst_gl_upload_debug);
@@ -357,7 +357,7 @@ gst_gl_upload_init (GstGLUpload * upload)
 {
   upload->priv = GST_GL_UPLOAD_GET_PRIVATE (upload);
 
-  upload->display = NULL;
+  upload->context = NULL;
 
   g_mutex_init (&upload->lock);
 
@@ -374,25 +374,25 @@ gst_gl_upload_init (GstGLUpload * upload)
 
 /**
  * gst_gl_upload_new:
- * @display: a #GstGLDisplay
+ * @context: a #GstGLContext
  *
  * Returns: a new #GstGLUpload object
  */
 GstGLUpload *
-gst_gl_upload_new (GstGLDisplay * display)
+gst_gl_upload_new (GstGLContext * context)
 {
   GstGLUpload *upload;
   GstGLUploadPrivate *priv;
 
   upload = g_object_new (GST_TYPE_GL_UPLOAD, NULL);
 
-  upload->display = gst_object_ref (display);
+  upload->context = gst_object_ref (context);
   priv = upload->priv;
 
   g_mutex_init (&upload->lock);
 
 #if GST_GL_HAVE_OPENGL
-  if (USING_OPENGL (display)) {
+  if (USING_OPENGL (context)) {
     priv->YUY2_UYVY = frag_YUY2_UYVY_opengl;
     priv->PLANAR_YUV = frag_PLANAR_YUV_opengl;
     priv->AYUV = frag_AYUV_opengl;
@@ -404,7 +404,7 @@ gst_gl_upload_new (GstGLDisplay * display)
   }
 #endif
 #if GST_GL_HAVE_GLES2
-  if (USING_GLES2 (display)) {
+  if (USING_GLES2 (context)) {
     priv->YUY2_UYVY = frag_YUY2_UYVY_gles2;
     priv->PLANAR_YUV = frag_PLANAR_YUV_gles2;
     priv->AYUV = frag_AYUV_gles2;
@@ -429,16 +429,16 @@ gst_gl_upload_finalize (GObject * object)
 
   for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
     if (upload->in_texture[i]) {
-      gst_gl_display_del_texture (upload->display, &upload->in_texture[i]);
+      gst_gl_context_del_texture (upload->context, &upload->in_texture[i]);
       upload->in_texture[i] = 0;
     }
   }
   if (upload->out_texture) {
-    gst_gl_display_del_texture (upload->display, &upload->out_texture);
+    gst_gl_context_del_texture (upload->context, &upload->out_texture);
     upload->out_texture = 0;
   }
   if (upload->fbo || upload->depth_buffer) {
-    gst_gl_display_del_fbo (upload->display, upload->fbo, upload->depth_buffer);
+    gst_gl_context_del_fbo (upload->context, upload->fbo, upload->depth_buffer);
     upload->fbo = 0;
     upload->depth_buffer = 0;
   }
@@ -447,9 +447,9 @@ gst_gl_upload_finalize (GObject * object)
     upload->shader = NULL;
   }
 
-  if (upload->display) {
-    gst_object_unref (upload->display);
-    upload->display = NULL;
+  if (upload->context) {
+    gst_object_unref (upload->context);
+    upload->context = NULL;
   }
 
   G_OBJECT_CLASS (gst_gl_upload_parent_class)->finalize (object);
@@ -495,8 +495,8 @@ gst_gl_upload_init_format (GstGLUpload * upload, GstVideoFormat v_format,
   upload->in_width = in_width;
   upload->in_height = in_height;
 
-  gst_gl_display_thread_add (upload->display,
-      (GstGLDisplayThreadFunc) _init_upload, upload);
+  gst_gl_context_thread_add (upload->context,
+      (GstGLContextThreadFunc) _init_upload, upload);
 
   g_mutex_unlock (&upload->lock);
 
@@ -594,14 +594,14 @@ _gst_gl_upload_perform_with_data_unlocked (GstGLUpload * upload,
     upload->data[i] = data[i];
   }
 
-  gst_gl_display_thread_add (upload->display,
-      (GstGLDisplayThreadFunc) _do_upload, upload);
+  gst_gl_context_thread_add (upload->context,
+      (GstGLContextThreadFunc) _do_upload, upload);
 
   return TRUE;
 }
 
 static gboolean
-_create_shader (GstGLDisplay * display, const gchar * vertex_src,
+_create_shader (GstGLContext * context, const gchar * vertex_src,
     const gchar * fragment_src, GstGLShader ** out_shader)
 {
   GstGLShader *shader;
@@ -609,7 +609,7 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
 
   g_return_val_if_fail (vertex_src != NULL || fragment_src != NULL, FALSE);
 
-  shader = gst_gl_shader_new (display);
+  shader = gst_gl_shader_new (context);
 
   if (vertex_src)
     gst_gl_shader_set_vertex_source (shader, vertex_src);
@@ -617,9 +617,9 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
     gst_gl_shader_set_fragment_source (shader, fragment_src);
 
   if (!gst_gl_shader_compile (shader, &error)) {
-    gst_gl_display_set_error (display, "%s", error->message);
+    gst_gl_context_set_error (context, "%s", error->message);
     g_error_free (error);
-    gst_gl_display_clear_shader (display);
+    gst_gl_context_clear_shader (context);
     gst_object_unref (shader);
     return FALSE;
   }
@@ -630,14 +630,14 @@ _create_shader (GstGLDisplay * display, const gchar * vertex_src,
 
 /* Called in the gl thread */
 void
-_init_upload (GstGLDisplay * display, GstGLUpload * upload)
+_init_upload (GstGLContext * context, GstGLUpload * upload)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
   gchar *frag_prog = NULL;
   gboolean free_frag_prog, res;
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   v_format = GST_VIDEO_INFO_FORMAT (&upload->info);
 
@@ -645,12 +645,12 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
       gst_video_format_to_string (v_format));
 
   if (!gl->CreateProgramObject && !gl->CreateProgram) {
-    gst_gl_display_set_error (display,
+    gst_gl_context_set_error (context,
         "Cannot upload YUV formats without OpenGL shaders");
     goto error;
   }
 
-  _init_upload_fbo (display, upload);
+  _init_upload_fbo (context, upload);
 
   switch (v_format) {
     case GST_VIDEO_FORMAT_AYUV:
@@ -710,7 +710,7 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
       upload->priv->n_textures = 2;
       break;
     case GST_VIDEO_FORMAT_UYVY:
-      if (USING_GLES2 (display)) {
+      if (USING_GLES2 (context)) {
         frag_prog = g_strdup_printf (upload->priv->YUY2_UYVY, 'a', 'r', 'b');
       } else {
         frag_prog = g_strdup_printf (upload->priv->YUY2_UYVY, 'a', 'b', 'r');
@@ -724,7 +724,7 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
   }
 
   res =
-      _create_shader (display, upload->priv->vert_shader, frag_prog,
+      _create_shader (context, upload->priv->vert_shader, frag_prog,
       &upload->shader);
   if (free_frag_prog)
     g_free (frag_prog);
@@ -732,14 +732,14 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
   if (!res)
     goto error;
 
-  if (USING_GLES2 (display)) {
+  if (USING_GLES2 (context)) {
     upload->shader_attr_position_loc =
         gst_gl_shader_get_attribute_location (upload->shader, "a_position");
     upload->shader_attr_texture_loc =
         gst_gl_shader_get_attribute_location (upload->shader, "a_texcoord");
   }
 
-  if (!_do_upload_make (display, upload))
+  if (!_do_upload_make (context, upload))
     goto error;
 
   upload->priv->result = TRUE;
@@ -752,20 +752,20 @@ error:
 
 /* called by _init_upload (in the gl thread) */
 gboolean
-_init_upload_fbo (GstGLDisplay * display, GstGLUpload * upload)
+_init_upload_fbo (GstGLContext * context, GstGLUpload * upload)
 {
   GstGLFuncs *gl;
   guint out_width, out_height;
   GLuint fake_texture = 0;      /* a FBO must hava texture to init */
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   out_width = GST_VIDEO_INFO_WIDTH (&upload->info);
   out_height = GST_VIDEO_INFO_HEIGHT (&upload->info);
 
   if (!gl->GenFramebuffers) {
     /* turn off the pipeline because Frame buffer object is a not present */
-    gst_gl_display_set_error (display,
+    gst_gl_context_set_error (context,
         "Context, EXT_framebuffer_object supported: no");
     return FALSE;
   }
@@ -779,13 +779,13 @@ _init_upload_fbo (GstGLDisplay * display, GstGLUpload * upload)
   /* setup the render buffer for depth */
   gl->GenRenderbuffers (1, &upload->depth_buffer);
   gl->BindRenderbuffer (GL_RENDERBUFFER, upload->depth_buffer);
-  if (USING_OPENGL (display)) {
+  if (USING_OPENGL (context)) {
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT,
         out_width, out_height);
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
         out_width, out_height);
   }
-  if (USING_GLES2 (display)) {
+  if (USING_GLES2 (context)) {
     gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
         out_width, out_height);
   }
@@ -812,13 +812,13 @@ _init_upload_fbo (GstGLDisplay * display, GstGLUpload * upload)
   gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
       GL_RENDERBUFFER, upload->depth_buffer);
 
-  if (USING_OPENGL (display)) {
+  if (USING_OPENGL (context)) {
     gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
         GL_RENDERBUFFER, upload->depth_buffer);
   }
 
-  if (!gst_gl_display_check_framebuffer_status (display)) {
-    gst_gl_display_set_error (display, "GL framebuffer status incomplete");
+  if (!gst_gl_context_check_framebuffer_status (context)) {
+    gst_gl_context_set_error (context, "GL framebuffer status incomplete");
     return FALSE;
   }
 
@@ -832,7 +832,7 @@ _init_upload_fbo (GstGLDisplay * display, GstGLUpload * upload)
 
 /* Called by the idle function in the gl thread */
 void
-_do_upload (GstGLDisplay * display, GstGLUpload * upload)
+_do_upload (GstGLContext * context, GstGLUpload * upload)
 {
   guint in_width, in_height, out_width, out_height;
 
@@ -846,10 +846,10 @@ _do_upload (GstGLDisplay * display, GstGLUpload * upload)
       out_width, out_height, upload->in_texture[0], upload->in_texture[1],
       upload->in_texture[2], in_width, in_height);
 
-  if (!_do_upload_fill (display, upload))
+  if (!_do_upload_fill (context, upload))
     goto error;
 
-  if (!upload->priv->draw (display, upload))
+  if (!upload->priv->draw (context, upload))
     goto error;
 
   upload->priv->result = TRUE;
@@ -867,9 +867,9 @@ struct TexData
   gint internal_format, format, type, width, height;
 };
 
-/* called by gst_gl_display_thread_do_upload (in the gl thread) */
+/* called by gst_gl_context_thread_do_upload (in the gl thread) */
 gboolean
-_do_upload_make (GstGLDisplay * display, GstGLUpload * upload)
+_do_upload_make (GstGLContext * context, GstGLUpload * upload)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
@@ -877,7 +877,7 @@ _do_upload_make (GstGLDisplay * display, GstGLUpload * upload)
   struct TexData tex[GST_VIDEO_MAX_PLANES];
   guint i;
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   in_width = upload->in_width;
   in_height = upload->in_height;
@@ -1020,7 +1020,7 @@ _do_upload_make (GstGLDisplay * display, GstGLUpload * upload)
       tex[2].height = in_height;
       break;
     default:
-      gst_gl_display_set_error (display, "Unsupported upload video format %d",
+      gst_gl_context_set_error (context, "Unsupported upload video format %d",
           v_format);
       g_assert_not_reached ();
       break;
@@ -1038,15 +1038,15 @@ _do_upload_make (GstGLDisplay * display, GstGLUpload * upload)
 }
 
 
-/* called by gst_gl_display_thread_do_upload (in the gl thread) */
+/* called by gst_gl_context_thread_do_upload (in the gl thread) */
 gboolean
-_do_upload_fill (GstGLDisplay * display, GstGLUpload * upload)
+_do_upload_fill (GstGLContext * context, GstGLUpload * upload)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
   guint in_width, in_height;
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   in_width = upload->in_width;
   in_height = upload->in_height;
@@ -1179,7 +1179,7 @@ _do_upload_fill (GstGLDisplay * display, GstGLUpload * upload)
     }
       break;
     default:
-      gst_gl_display_set_error (display, "Unsupported upload video format %d",
+      gst_gl_context_set_error (context, "Unsupported upload video format %d",
           v_format);
       g_assert_not_reached ();
       break;
@@ -1196,7 +1196,7 @@ _do_upload_fill (GstGLDisplay * display, GstGLUpload * upload)
 #if GST_GL_HAVE_OPENGL
 /* called by _do_upload (in the gl thread) */
 static gboolean
-_do_upload_draw_opengl (GstGLDisplay * display, GstGLUpload * upload)
+_do_upload_draw_opengl (GstGLContext * context, GstGLUpload * upload)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
@@ -1218,7 +1218,7 @@ _do_upload_draw_opengl (GstGLDisplay * display, GstGLUpload * upload)
     in_width, in_height
   };
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   out_width = GST_VIDEO_INFO_WIDTH (&upload->info);
   out_height = GST_VIDEO_INFO_HEIGHT (&upload->info);
@@ -1234,7 +1234,7 @@ _do_upload_draw_opengl (GstGLDisplay * display, GstGLUpload * upload)
   gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
       GL_TEXTURE_RECTANGLE_ARB, upload->out_texture, 0);
 
-  gst_gl_display_clear_shader (display);
+  gst_gl_context_clear_shader (context);
 
   gl->PushAttrib (GL_VIEWPORT_BIT);
 
@@ -1299,7 +1299,7 @@ _do_upload_draw_opengl (GstGLDisplay * display, GstGLUpload * upload)
       break;
 
     default:
-      gst_gl_display_set_error (display, "Unsupported upload video format %d",
+      gst_gl_context_set_error (context, "Unsupported upload video format %d",
           v_format);
       g_assert_not_reached ();
       break;
@@ -1347,7 +1347,7 @@ _do_upload_draw_opengl (GstGLDisplay * display, GstGLUpload * upload)
   gl->DrawBuffer (GL_NONE);
 
   /* we are done with the shader */
-  gst_gl_display_clear_shader (display);
+  gst_gl_context_clear_shader (context);
 
   gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
 
@@ -1357,7 +1357,7 @@ _do_upload_draw_opengl (GstGLDisplay * display, GstGLUpload * upload)
   gl->PopMatrix ();
   gl->PopAttrib ();
 
-  gst_gl_display_check_framebuffer_status (display);
+  gst_gl_context_check_framebuffer_status (context);
 
   gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
 
@@ -1367,7 +1367,7 @@ _do_upload_draw_opengl (GstGLDisplay * display, GstGLUpload * upload)
 
 #if GST_GL_HAVE_GLES2
 static gboolean
-_do_upload_draw_gles2 (GstGLDisplay * display, GstGLUpload * upload)
+_do_upload_draw_gles2 (GstGLContext * context, GstGLUpload * upload)
 {
   GstGLFuncs *gl;
   GstVideoFormat v_format;
@@ -1390,7 +1390,7 @@ _do_upload_draw_gles2 (GstGLDisplay * display, GstGLUpload * upload)
 
   GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
 
-  gl = display->gl_vtable;
+  gl = context->gl_vtable;
 
   out_width = GST_VIDEO_INFO_WIDTH (&upload->info);
   out_height = GST_VIDEO_INFO_HEIGHT (&upload->info);
@@ -1405,7 +1405,7 @@ _do_upload_draw_gles2 (GstGLDisplay * display, GstGLUpload * upload)
   gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
       GL_TEXTURE_RECTANGLE_ARB, upload->out_texture, 0);
 
-  gst_gl_display_clear_shader (display);
+  gst_gl_context_clear_shader (context);
 
   gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
 
@@ -1458,7 +1458,7 @@ _do_upload_draw_gles2 (GstGLDisplay * display, GstGLUpload * upload)
       texnames[0] = "tex";
       break;
     default:
-      gst_gl_display_set_error (display, "Unsupported upload video format %d",
+      gst_gl_context_set_error (context, "Unsupported upload video format %d",
           v_format);
       g_assert_not_reached ();
       break;
@@ -1498,12 +1498,12 @@ _do_upload_draw_gles2 (GstGLDisplay * display, GstGLUpload * upload)
   gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
 
   /* we are done with the shader */
-  gst_gl_display_clear_shader (display);
+  gst_gl_context_clear_shader (context);
 
   gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
       viewport_dim[3]);
 
-  gst_gl_display_check_framebuffer_status (display);
+  gst_gl_context_check_framebuffer_status (context);
 
   gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
 
index 7ce06d5..4b5660c 100644 (file)
@@ -51,7 +51,7 @@ struct _GstGLUpload
 
   GMutex           lock;
 
-  GstGLDisplay    *display;
+  GstGLContext    *context;
 
   /* input data */
   GstVideoInfo    info;
@@ -103,7 +103,7 @@ struct _GstGLUploadClass
  */
 #define GST_GL_UPLOAD_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_GL_UPLOAD_FORMATS)
 
-GstGLUpload * gst_gl_upload_new            (GstGLDisplay * display);
+GstGLUpload * gst_gl_upload_new            (GstGLContext * context);
 
 gboolean gst_gl_upload_init_format         (GstGLUpload * upload, GstVideoFormat v_format,
                                             guint in_width, guint in_height,
index 68b658e..64ac0c5 100644 (file)
 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
 #endif
 
-#define USING_OPENGL(display) (display->gl_api & GST_GL_API_OPENGL)
-#define USING_OPENGL3(display) (display->gl_api & GST_GL_API_OPENGL3)
-#define USING_GLES(display) (display->gl_api & GST_GL_API_GLES)
-#define USING_GLES2(display) (display->gl_api & GST_GL_API_GLES2)
-#define USING_GLES3(display) (display->gl_api & GST_GL_API_GLES3)
+#define USING_OPENGL(context) (gst_gl_context_get_gl_apie (context) & GST_GL_API_OPENGL)
+#define USING_OPENGL3(context) (gst_gl_context_get_gl_apie (context) & GST_GL_API_OPENGL3)
+#define USING_GLES(context) (gst_gl_context_get_gl_apie (context) & GST_GL_API_GLES)
+#define USING_GLES2(context) (gst_gl_context_get_gl_apie (context)->gl_api & GST_GL_API_GLES2)
+#define USING_GLES3(context) (gst_gl_context_get_gl_apie (context) & GST_GL_API_GLES3)
 
 static GLuint gen_texture;
 static GLuint gen_texture_width;
@@ -60,19 +60,19 @@ static GLuint *del_texture;
 static gchar *error_message;
 
 static void
-gst_gl_display_gen_texture_window_cb (GstGLDisplay * display)
+gst_gl_context_gen_texture_window_cb (GstGLContext * context)
 {
-  gst_gl_display_gen_texture_thread (display, &gen_texture,
+  gst_gl_context_gen_texture_thread (context, &gen_texture,
       gen_texture_video_format, gen_texture_width, gen_texture_height);
 }
 
 /* Generate a texture if no one is available in the pool
  * Called in the gl thread */
 void
-gst_gl_display_gen_texture_thread (GstGLDisplay * display, GLuint * pTexture,
+gst_gl_context_gen_texture_thread (GstGLContext * context, GLuint * pTexture,
     GstVideoFormat v_format, GLint width, GLint height)
 {
-  const GstGLFuncs *gl = display->gl_vtable;
+  const GstGLFuncs *gl = context->gl_vtable;
 
   GST_TRACE ("Generating texture format:%u dimensions:%ux%u", v_format,
       width, height);
@@ -95,18 +95,18 @@ gst_gl_display_gen_texture_thread (GstGLDisplay * display, GLuint * pTexture,
 }
 
 void
-gst_gl_display_del_texture_window_cb (GstGLDisplay * display)
+gst_gl_context_del_texture_window_cb (GstGLContext * context)
 {
-  const GstGLFuncs *gl = display->gl_vtable;
+  const GstGLFuncs *gl = context->gl_vtable;
   gl->DeleteTextures (1, del_texture);
 }
 
 /* called in the gl thread */
 gboolean
-gst_gl_display_check_framebuffer_status (GstGLDisplay * display)
+gst_gl_context_check_framebuffer_status (GstGLContext * context)
 {
   GLenum status = 0;
-  status = display->gl_vtable->CheckFramebufferStatus (GL_FRAMEBUFFER);
+  status = context->gl_vtable->CheckFramebufferStatus (GL_FRAMEBUFFER);
 
   switch (status) {
     case GL_FRAMEBUFFER_COMPLETE:
@@ -140,35 +140,11 @@ gst_gl_display_check_framebuffer_status (GstGLDisplay * display)
 }
 
 void
-gst_gl_display_activate_gl_context (GstGLDisplay * display, gboolean activate)
-{
-  GstGLContext *context;
-
-  g_return_if_fail (GST_IS_GL_DISPLAY (display));
-
-  if (!activate)
-    gst_gl_display_lock (display);
-
-  context = gst_gl_display_get_context_unlocked (display);
-
-  gst_gl_context_activate (context, activate);
-
-  if (activate)
-    gst_gl_display_unlock (display);
-
-  gst_object_unref (context);
-}
-
-void
-gst_gl_display_gen_texture (GstGLDisplay * display, GLuint * pTexture,
+gst_gl_context_gen_texture (GstGLContext * context, GLuint * pTexture,
     GstVideoFormat v_format, GLint width, GLint height)
 {
-  GstGLContext *context;
   GstGLWindow *window;
 
-  gst_gl_display_lock (display);
-
-  context = gst_gl_display_get_context_unlocked (display);
   window = gst_gl_context_get_window (context);
 
   if (gst_gl_window_is_running (window)) {
@@ -176,37 +152,27 @@ gst_gl_display_gen_texture (GstGLDisplay * display, GLuint * pTexture,
     gen_texture_height = height;
     gen_texture_video_format = v_format;
     gst_gl_window_send_message (window,
-        GST_GL_WINDOW_CB (gst_gl_display_gen_texture_window_cb), display);
+        GST_GL_WINDOW_CB (gst_gl_context_gen_texture_window_cb), context);
     *pTexture = gen_texture;
   } else
     *pTexture = 0;
 
-  gst_object_unref (context);
   gst_object_unref (window);
-
-  gst_gl_display_unlock (display);
 }
 
 void
-gst_gl_display_del_texture (GstGLDisplay * display, GLuint * pTexture)
+gst_gl_context_del_texture (GstGLContext * context, GLuint * pTexture)
 {
-  GstGLContext *context;
   GstGLWindow *window;
 
-  gst_gl_display_lock (display);
-
-  context = gst_gl_display_get_context_unlocked (display);
   window = gst_gl_context_get_window (context);
   if (gst_gl_window_is_running (window) && *pTexture) {
     del_texture = pTexture;
     gst_gl_window_send_message (window,
-        GST_GL_WINDOW_CB (gst_gl_display_del_texture_window_cb), display);
+        GST_GL_WINDOW_CB (gst_gl_context_del_texture_window_cb), context);
   }
 
-  gst_object_unref (context);
   gst_object_unref (window);
-
-  gst_gl_display_unlock (display);
 }
 
 typedef struct _GenFBO
@@ -217,21 +183,21 @@ typedef struct _GenFBO
 } GenFBO;
 
 static void
-_gen_fbo (GstGLDisplay * display, GenFBO * data)
+_gen_fbo (GstGLContext * context, GenFBO * data)
 {
   gst_gl_framebuffer_generate (data->frame, data->width, data->height,
       data->fbo, data->depth);
 }
 
 gboolean
-gst_gl_display_gen_fbo (GstGLDisplay * display, gint width, gint height,
+gst_gl_context_gen_fbo (GstGLContext * context, gint width, gint height,
     GLuint * fbo, GLuint * depthbuffer)
 {
-  GstGLFramebuffer *frame = gst_gl_framebuffer_new (display);
+  GstGLFramebuffer *frame = gst_gl_framebuffer_new (context);
 
   GenFBO data = { frame, width, height, fbo, depthbuffer };
 
-  gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _gen_fbo, &data);
+  gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _gen_fbo, &data);
 
   gst_object_unref (frame);
 
@@ -259,7 +225,7 @@ typedef struct _UseFBO
 } UseFBO;
 
 static void
-_use_fbo (GstGLDisplay * display, UseFBO * data)
+_use_fbo (GstGLContext * context, UseFBO * data)
 {
   gst_gl_framebuffer_use (data->frame, data->texture_fbo_width,
       data->texture_fbo_height, data->fbo, data->depth_buffer,
@@ -278,14 +244,14 @@ _use_fbo (GstGLDisplay * display, UseFBO * data)
  * GstGLDisplay *display and gpointer data, or just gpointer data */
 /* ..everything here has to be simplified! */
 gboolean
-gst_gl_display_use_fbo (GstGLDisplay * display, gint texture_fbo_width,
+gst_gl_context_use_fbo (GstGLContext * context, gint texture_fbo_width,
     gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
     GLuint texture_fbo, GLCB cb, gint input_tex_width,
     gint input_tex_height, GLuint input_tex, gdouble proj_param1,
     gdouble proj_param2, gdouble proj_param3, gdouble proj_param4,
     GstGLDisplayProjection projection, gpointer stuff)
 {
-  GstGLFramebuffer *frame = gst_gl_framebuffer_new (display);
+  GstGLFramebuffer *frame = gst_gl_framebuffer_new (context);
 
   UseFBO data =
       { frame, texture_fbo_width, texture_fbo_height, fbo, depth_buffer,
@@ -293,7 +259,7 @@ gst_gl_display_use_fbo (GstGLDisplay * display, gint texture_fbo_width,
     proj_param1, proj_param2, proj_param3, proj_param4, projection, stuff
   };
 
-  gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _use_fbo, &data);
+  gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _use_fbo, &data);
 
   gst_object_unref (frame);
 
@@ -313,7 +279,7 @@ typedef struct _UseFBO2
 } UseFBO2;
 
 static void
-_use_fbo_v2 (GstGLDisplay * display, UseFBO2 * data)
+_use_fbo_v2 (GstGLContext * context, UseFBO2 * data)
 {
   gst_gl_framebuffer_use_v2 (data->frame, data->texture_fbo_width,
       data->texture_fbo_height, data->fbo, data->depth_buffer,
@@ -321,18 +287,18 @@ _use_fbo_v2 (GstGLDisplay * display, UseFBO2 * data)
 }
 
 gboolean
-gst_gl_display_use_fbo_v2 (GstGLDisplay * display, gint texture_fbo_width,
+gst_gl_context_use_fbo_v2 (GstGLContext * context, gint texture_fbo_width,
     gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
     GLuint texture_fbo, GLCB_V2 cb, gpointer stuff)
 {
-  GstGLFramebuffer *frame = gst_gl_framebuffer_new (display);
+  GstGLFramebuffer *frame = gst_gl_framebuffer_new (context);
 
   UseFBO2 data =
       { frame, texture_fbo_width, texture_fbo_height, fbo, depth_buffer,
     texture_fbo, cb, stuff
   };
 
-  gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _use_fbo_v2,
+  gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _use_fbo_v2,
       &data);
 
   gst_object_unref (frame);
@@ -349,35 +315,35 @@ typedef struct _DelFBO
 
 /* Called in the gl thread */
 static void
-_del_fbo (GstGLDisplay * display, DelFBO * data)
+_del_fbo (GstGLContext * context, DelFBO * data)
 {
   gst_gl_framebuffer_delete (data->frame, data->fbo, data->depth);
 }
 
 /* Called by gltestsrc and glfilter */
 void
-gst_gl_display_del_fbo (GstGLDisplay * display, GLuint fbo, GLuint depth_buffer)
+gst_gl_context_del_fbo (GstGLContext * context, GLuint fbo, GLuint depth_buffer)
 {
-  GstGLFramebuffer *frame = gst_gl_framebuffer_new (display);
+  GstGLFramebuffer *frame = gst_gl_framebuffer_new (context);
 
   DelFBO data = { frame, fbo, depth_buffer };
 
-  gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _del_fbo, &data);
+  gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _del_fbo, &data);
 
   gst_object_unref (frame);
 }
 
 static void
-_compile_shader (GstGLDisplay * display, GstGLShader ** shader)
+_compile_shader (GstGLContext * context, GstGLShader ** shader)
 {
   GError *error = NULL;
 
   gst_gl_shader_compile (*shader, &error);
   if (error) {
-    gst_gl_display_set_error (display, "%s", error->message);
+    gst_gl_context_set_error (context, "%s", error->message);
     g_error_free (error);
     error = NULL;
-    gst_gl_display_clear_shader (display);
+    gst_gl_context_clear_shader (context);
     gst_object_unref (*shader);
     *shader = NULL;
   }
@@ -385,27 +351,27 @@ _compile_shader (GstGLDisplay * display, GstGLShader ** shader)
 
 /* Called by glfilter */
 gboolean
-gst_gl_display_gen_shader (GstGLDisplay * display, const gchar * vert_src,
+gst_gl_context_gen_shader (GstGLContext * context, const gchar * vert_src,
     const gchar * frag_src, GstGLShader ** shader)
 {
   g_return_val_if_fail (frag_src != NULL || vert_src != NULL, FALSE);
   g_return_val_if_fail (shader != NULL, FALSE);
 
-  *shader = gst_gl_shader_new (display);
+  *shader = gst_gl_shader_new (context);
 
   if (frag_src)
     gst_gl_shader_set_fragment_source (*shader, frag_src);
   if (vert_src)
     gst_gl_shader_set_vertex_source (*shader, vert_src);
 
-  gst_gl_display_thread_add (display, (GstGLDisplayThreadFunc) _compile_shader,
+  gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _compile_shader,
       shader);
 
   return *shader != NULL;
 }
 
 void
-gst_gl_display_set_error (GstGLDisplay * display, const char *format, ...)
+gst_gl_context_set_error (GstGLContext * context, const char *format, ...)
 {
   va_list args;
 
@@ -420,14 +386,14 @@ gst_gl_display_set_error (GstGLDisplay * display, const char *format, ...)
 }
 
 gchar *
-gst_gl_display_get_error (void)
+gst_gl_context_get_error (void)
 {
   return error_message;
 }
 
 /* Called by glfilter */
 void
-gst_gl_display_del_shader (GstGLDisplay * display, GstGLShader * shader)
+gst_gl_context_del_shader (GstGLContext * context, GstGLShader * shader)
 {
   gst_object_unref (shader);
 }
index 421398c..037c895 100644 (file)
@@ -26,7 +26,7 @@
 #include <gst/gl/gstgl_fwd.h>
 
 /**
- * GstGLDisplayProjection:
+ * GstGLContextProjection:
  *
  * %GST_GL_DISPLAY_PROJECTION_ORTHO2D: Orthogonal projection
  * %GST_GL_DISPLAY_CONVERSION_MATRIX: Perspective projection 
@@ -74,35 +74,34 @@ typedef void (*GLCB) (gint, gint, guint, gpointer stuff);
  */
 typedef void (*GLCB_V2) (gpointer stuff);
 
-void gst_gl_display_gen_texture (GstGLDisplay * display, GLuint * pTexture,
+void gst_gl_context_gen_texture (GstGLContext * context, GLuint * pTexture,
     GstVideoFormat v_format, GLint width, GLint height);
-void gst_gl_display_gen_texture_thread (GstGLDisplay * display, GLuint * pTexture,
+void gst_gl_context_gen_texture_thread (GstGLContext * context, GLuint * pTexture,
     GstVideoFormat v_format, GLint width, GLint height);
-void gst_gl_display_del_texture (GstGLDisplay * display, GLuint * pTexture);
+void gst_gl_context_del_texture (GstGLContext * context, GLuint * pTexture);
 
-gboolean gst_gl_display_gen_fbo (GstGLDisplay * display, gint width, gint height,
+gboolean gst_gl_context_gen_fbo (GstGLContext * context, gint width, gint height,
     GLuint * fbo, GLuint * depthbuffer);
-gboolean gst_gl_display_use_fbo (GstGLDisplay * display, gint texture_fbo_width,
+gboolean gst_gl_context_use_fbo (GstGLContext * context, gint texture_fbo_width,
     gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
     GLuint texture_fbo, GLCB cb, gint input_texture_width,
     gint input_texture_height, GLuint input_texture, gdouble proj_param1,
     gdouble proj_param2, gdouble proj_param3, gdouble proj_param4,
     GstGLDisplayProjection projection, gpointer stuff);
-gboolean gst_gl_display_use_fbo_v2 (GstGLDisplay * display, gint texture_fbo_width,
+gboolean gst_gl_context_use_fbo_v2 (GstGLContext * context, gint texture_fbo_width,
     gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
     GLuint texture_fbo, GLCB_V2 cb, gpointer stuff);
-void gst_gl_display_del_fbo (GstGLDisplay * display, GLuint fbo,
+void gst_gl_context_del_fbo (GstGLContext * context, GLuint fbo,
     GLuint depth_buffer);
 
-gboolean gst_gl_display_gen_shader (GstGLDisplay * display,
+gboolean gst_gl_context_gen_shader (GstGLContext * context,
     const gchar * shader_vertex_source,
     const gchar * shader_fragment_source, GstGLShader ** shader);
-void gst_gl_display_del_shader (GstGLDisplay * display, GstGLShader * shader);
+void gst_gl_context_del_shader (GstGLContext * context, GstGLShader * shader);
 
-gboolean gst_gl_display_check_framebuffer_status (GstGLDisplay * display);
-void gst_gl_display_activate_gl_context (GstGLDisplay * display, gboolean activate);
+gboolean gst_gl_context_check_framebuffer_status (GstGLContext * context);
 
-void gst_gl_display_set_error (GstGLDisplay * display, const char * format, ...);
-gchar *gst_gl_display_get_error (void);
+void gst_gl_context_set_error (GstGLContext * context, const char * format, ...);
+gchar *gst_gl_context_get_error (void);
 
 #endif /* __GST_GL_UTILS_H__ */
index d3675cb..5f4ebb4 100644 (file)
@@ -77,14 +77,15 @@ static GLint shader_attr_texture_loc;
 void
 init (gpointer data)
 {
+  GstGLContext *context = data;
+
   /* has to be called in the thread that is going to use the framebuffer */
-  fbo = gst_gl_framebuffer_new (display);
+  fbo = gst_gl_framebuffer_new (context);
 
   gst_gl_framebuffer_generate (fbo, 320, 240, &fbo_id, &rbo);
   fail_if (fbo == NULL || fbo_id == 0, "failed to create framebuffer object");
 
-  gst_gl_display_gen_texture_thread (display, &tex, GST_VIDEO_FORMAT_RGBA, 320,
-      240);
+  gst_gl_context_gen_texture (context, &tex, GST_VIDEO_FORMAT_RGBA, 320, 240);
   fail_if (tex == 0, "failed to create texture");
 
 #if GST_GL_HAVE_GLES2
@@ -109,7 +110,8 @@ init (gpointer data)
 void
 deinit (gpointer data)
 {
-  GstGLFuncs *gl = display->gl_vtable;
+  GstGLContext *context = data;
+  GstGLFuncs *gl = context->gl_vtable;
   gl->DeleteTextures (1, &tex);;
   gst_object_unref (fbo);
 #if GST_GL_HAVE_GLES2
@@ -120,8 +122,9 @@ deinit (gpointer data)
 void
 clear_tex (gpointer data)
 {
+  GstGLContext *context = data;
+  GstGLFuncs *gl = context->gl_vtable;
   static gfloat r = 0.0, g = 0.0, b = 0.0;
-  GstGLFuncs *gl = display->gl_vtable;
 
   gl->ClearColor (r, g, b, 1.0);
   gl->Clear (GL_COLOR_BUFFER_BIT);
@@ -141,9 +144,9 @@ draw_tex (gpointer data)
 void
 draw_render (gpointer data)
 {
-  GstGLFuncs *gl = display->gl_vtable;
   GstGLContext *context = data;
   GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context);
+  const GstGLFuncs *gl = context->gl_vtable;
 
   /* redraw the texture into the system provided framebuffer */
 
index 3ac19e0..985129a 100644 (file)
@@ -74,7 +74,7 @@ GST_START_TEST (test_basic)
 
     /* test allocator creation */
     ASSERT_WARNING (mem = gst_allocator_alloc (gl_allocator, 0, NULL););
-    mem = gst_gl_memory_alloc (display, formats[i], width, height);
+    mem = gst_gl_memory_alloc (context, formats[i], width, height);
     fail_if (mem == NULL);
     gl_mem = (GstGLMemory *) mem;
 
@@ -82,7 +82,7 @@ GST_START_TEST (test_basic)
     fail_if (gl_mem->width != width);
     fail_if (gl_mem->height != height);
     fail_if (gl_mem->v_format != formats[i]);
-    fail_if (gl_mem->display != display);
+    fail_if (gl_mem->context != context);
     fail_if (gl_mem->tex_id == 0);
 
     /* copy the memory */
@@ -96,12 +96,12 @@ GST_START_TEST (test_basic)
     fail_if (gl_mem->height != gl_mem->height);
     fail_if (gl_mem->v_format != gl_mem->v_format);
     fail_if (gl_mem->gl_format != gl_mem->gl_format);
-    fail_if (gl_mem->display != gl_mem->display);
+    fail_if (gl_mem->context != gl_mem->context);
     fail_if (gl_mem->tex_id == 0);
 
-    if (gst_gl_display_get_error ())
-      printf ("%s\n", gst_gl_display_get_error ());
-    fail_if (gst_gl_display_get_error () != NULL);
+    if (gst_gl_context_get_error ())
+      printf ("%s\n", gst_gl_context_get_error ());
+    fail_if (gst_gl_context_get_error () != NULL);
 
     gst_memory_unref (mem);
     gst_memory_unref (mem2);