summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <ystreet00@gmail.com>2013-08-21 13:57:56 +1000
committerMatthew Waters <ystreet00@gmail.com>2013-08-22 01:30:04 +1000
commit267a06813c43dfaa129c8d35213a7b682d39fc78 (patch)
treedaf9e0ad6a4a26b3e91888aebb0e87ed2a45439b
parent360ef9d174aee9a07fed1550bbd43502d9782690 (diff)
android: port to GstGLContext
not tested
-rw-r--r--gst-libs/gst/gl/android/gstglwindow_android_egl.c122
1 files changed, 23 insertions, 99 deletions
diff --git a/gst-libs/gst/gl/android/gstglwindow_android_egl.c b/gst-libs/gst/gl/android/gstglwindow_android_egl.c
index 78ab730..f1bdf66 100644
--- a/gst-libs/gst/gl/android/gstglwindow_android_egl.c
+++ b/gst-libs/gst/gl/android/gstglwindow_android_egl.c
@@ -39,9 +39,8 @@
G_DEFINE_TYPE (GstGLWindowAndroidEGL, gst_gl_window_android_egl,
GST_GL_TYPE_WINDOW);
-static guintptr gst_gl_window_android_egl_get_gl_context (GstGLWindow * window);
-static gboolean gst_gl_window_android_egl_activate (GstGLWindow * window,
- gboolean activate);
+static guintptr gst_gl_window_android_egl_get_window_handle (GstGLWindow *
+ window);
static void gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
guintptr handle);
static void gst_gl_window_android_egl_draw (GstGLWindow * window, guint width,
@@ -51,13 +50,8 @@ static void gst_gl_window_android_egl_quit (GstGLWindow * window,
GstGLWindowCB callback, gpointer data);
static void gst_gl_window_android_egl_send_message (GstGLWindow * window,
GstGLWindowCB callback, gpointer data);
-static void gst_gl_window_android_egl_destroy_context (GstGLWindowAndroidEGL *
- window_egl);
-static gboolean gst_gl_window_android_egl_create_context (GstGLWindow
- * window, GstGLAPI gl_api, guintptr external_gl_context, GError ** error);
-static GstGLAPI gst_gl_window_android_egl_get_gl_api (GstGLWindow * window);
-static gpointer gst_gl_window_android_egl_get_proc_address (GstGLWindow *
- window, const gchar * name);
+static gboolean gst_gl_window_android_egl_open (GstGLWindow * window,
+ GError ** error);
static void gst_gl_window_android_egl_close (GstGLWindow * window);
static void
@@ -65,12 +59,8 @@ gst_gl_window_android_egl_class_init (GstGLWindowAndroidEGLClass * klass)
{
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
- window_class->create_context =
- GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_create_context);
- window_class->get_gl_context =
- GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_gl_context);
- window_class->activate =
- GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_activate);
+ window_class->get_window_handle =
+ GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_window_handle);
window_class->set_window_handle =
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_set_window_handle);
window_class->draw_unlocked =
@@ -80,10 +70,7 @@ gst_gl_window_android_egl_class_init (GstGLWindowAndroidEGLClass * klass)
window_class->quit = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_quit);
window_class->send_message =
GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_send_message);
- window_class->get_gl_api =
- GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_gl_api);
- window_class->get_proc_address =
- GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_get_proc_address);
+ window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_open);
window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_android_egl_close);
}
@@ -107,84 +94,28 @@ gst_gl_window_android_egl_new (void)
return window;
}
-static void
-gst_gl_window_android_egl_close (GstGLWindow * window)
+static gboolean
+gst_gl_window_android_egl_open (GstGLWindow * window, GError ** error)
{
GstGLWindowAndroidEGL *window_egl;
window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
- gst_gl_window_android_egl_destroy_context (window_egl);
-}
-
-gboolean
-gst_gl_window_android_egl_create_context (GstGLWindow * window,
- GstGLAPI gl_api, guintptr external_gl_context, GError ** error)
-{
- GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
-
window_egl->main_context = g_main_context_new ();
window_egl->loop = g_main_loop_new (window_egl->main_context, FALSE);
- window_egl->egl =
- gst_gl_egl_create_context (eglGetDisplay (EGL_DEFAULT_DISPLAY),
- window_egl->native_window, gl_api, external_gl_context, error);
- if (!window_egl->egl)
- goto failure;
-
return TRUE;
-
-failure:
- return FALSE;
}
static void
-gst_gl_window_android_egl_destroy_context (GstGLWindowAndroidEGL * window_egl)
-{
- gst_gl_egl_activate (window_egl->egl, FALSE);
- gst_gl_egl_destroy_context (window_egl->egl);
- window_egl->egl = NULL;
-
- g_main_loop_unref (window_egl->loop);
- g_main_context_unref (window_egl->main_context);
-}
-
-static gboolean
-gst_gl_window_android_egl_activate (GstGLWindow * window, gboolean activate)
-{
- GstGLWindowAndroidEGL *window_egl;
-
- window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
-
- return gst_gl_egl_activate (window_egl->egl, activate);
-}
-
-static guintptr
-gst_gl_window_android_egl_get_gl_context (GstGLWindow * window)
-{
- GstGLWindowAndroidEGL *window_egl;
-
- window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
-
- return gst_gl_egl_get_gl_context (window_egl->egl);
-}
-
-static GstGLAPI
-gst_gl_window_android_egl_get_gl_api (GstGLWindow * window)
+gst_gl_window_android_egl_close (GstGLWindow * window)
{
GstGLWindowAndroidEGL *window_egl;
window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
- return gst_gl_egl_get_gl_api (window_egl->egl);
-}
-
-static void
-gst_gl_window_android_egl_swap_buffers (GstGLWindow * window)
-{
- GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
-
- gst_gl_egl_swap_buffers (window_egl->egl);
+ g_main_loop_unref (window_egl->loop);
+ g_main_context_unref (window_egl->main_context);
}
static void
@@ -275,6 +206,14 @@ gst_gl_window_android_egl_set_window_handle (GstGLWindow * window,
window_egl->native_window = (EGLNativeWindowType) handle;
}
+static guintptr
+gst_gl_window_android_egl_get_window_handle (GstGLWindow * window)
+{
+ GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
+
+ return (guintptr) window_egl->native_window;
+}
+
struct draw
{
GstGLWindowAndroidEGL *window;
@@ -287,11 +226,13 @@ draw_cb (gpointer data)
struct draw *draw_data = data;
GstGLWindowAndroidEGL *window_egl = draw_data->window;
GstGLWindow *window = GST_GL_WINDOW (window_egl);
+ GstGLContext *context = window->context;
+ GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (window->context);
if (window->draw)
window->draw (window->draw_data);
- gst_gl_window_android_egl_swap_buffers (window);
+ context_class->swap_buffers (context);
}
static void
@@ -305,20 +246,3 @@ gst_gl_window_android_egl_draw (GstGLWindow * window, guint width, guint height)
gst_gl_window_send_message (window, (GstGLWindowCB) draw_cb, &draw_data);
}
-
-static gpointer
-gst_gl_window_android_egl_get_proc_address (GstGLWindow * window,
- const gchar * name)
-{
- GstGLContext *context = NULL;
- GstGLWindowAndroidEGL *window_egl;
- gpointer result;
-
- window_egl = GST_GL_WINDOW_ANDROID_EGL (window);
-
- if (!(result = gst_gl_egl_get_proc_address (window_egl->egl, name))) {
- result = gst_gl_context_default_get_proc_address (context, name);
- }
-
- return result;
-}