Commit 9cbb652b authored by Matthew Waters's avatar Matthew Waters 🐨 Committed by Tim-Philipp Müller

[794/906] context: add subclasses for the different platforms (egl, glx, wgl, etc)

- most code taken from the Window subclasses
- tested combinations: xEGL, GLX, Wayland+EGL, Cocoa (under GNUStep), WGL (Wine)
parent e80533dc
......@@ -3,10 +3,13 @@
noinst_LTLIBRARIES = libgstgl-cocoa.la
libgstgl_cocoa_la_SOURCES = \
gstglwindow_cocoa.m
gstglwindow_cocoa.m \
gstglcontext_cocoa.m
noinst_HEADERS = \
gstglwindow_cocoa.h
gstglwindow_cocoa.h \
gstglcontext_cocoa.h \
gstgl_cocoa_private.h
libgstgl_cocoa_la_CFLAGS = \
-I$(top_srcdir)/gst-libs \
......
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_GL_COCOA_PRIVATE_H__
#define __GST_GL_COCOA_PRIVATE_H__
#include <gst/gst.h>
#include <Cocoa/Cocoa.h>
#include "gstglwindow_cocoa.h"
#include "gstglcontext_cocoa.h"
G_BEGIN_DECLS
@interface AppThreadPerformer : NSObject {
GstGLWindowCocoa *m_cocoa;
GstGLWindowCB m_callback;
GstGLWindowResizeCB m_callback2;
gpointer m_data;
gint m_width;
gint m_height;
}
- (id) init: (GstGLWindowCocoa *)window;
- (id) initWithCallback:(GstGLWindowCocoa *)window callback:(GstGLWindowCB)callback userData:(gpointer) data;
- (id) initWithSize: (GstGLWindowCocoa *)window callback:(GstGLWindowResizeCB)callback userData:(gpointer)data toSize:(NSSize)size;
- (id) initWithAll: (GstGLWindowCocoa *)window callback:(GstGLWindowCB)callback userData:(gpointer) data;
- (void) updateWindow;
- (void) sendToApp;
- (void) setWindow;
- (void) stopApp;
- (void) closeWindow;
@end
struct _GstGLContextCocoaPrivate
{
NSOpenGLContext *gl_context;
NSOpenGLContext *external_gl_context;
NSRect rect;
};
/* =============================================================*/
/* */
/* GstGLNSOpenGLView declaration */
/* */
/* =============================================================*/
@interface GstGLNSOpenGLView: NSOpenGLView {
GstGLWindowCocoa *m_cocoa;
gint m_resizeCount;
}
- (id) initWithFrame:(GstGLWindowCocoa *)window rect:(NSRect)contentRect
pixelFormat:(NSOpenGLPixelFormat *)fmt;
@end
gboolean gst_gl_window_cocoa_create_window (GstGLWindowCocoa *window_cocoa);
G_END_DECLS
#endif /* __GST_GL_COCOA_PRIVATE_H__ */
......@@ -18,47 +18,50 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_GL_WINDOW_X11_EGL_H__
#define __GST_GL_WINDOW_X11_EGL_H__
#ifndef __GST_GL_CONTEXT_COCOA_H__
#define __GST_GL_CONTEXT_COCOA_H__
#include "gstglwindow_x11.h"
#include "../gstglegl.h"
#include <gst/gst.h>
#include <EGL/egl.h>
#include <gst/gl/gl.h>
G_BEGIN_DECLS
#define GST_GL_TYPE_WINDOW_X11_EGL (gst_gl_window_x11_egl_get_type())
#define GST_GL_WINDOW_X11_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_GL_TYPE_WINDOW_X11_EGL, GstGLWindowX11EGL))
#define GST_GL_WINDOW_X11_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_GL_TYPE_WINDOW_X11_EGL, GstGLWindowX11EGLClass))
#define GST_GL_IS_WINDOW_X11_EGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_GL_TYPE_WINDOW_X11_EGL))
#define GST_GL_IS_WINDOW_X11_EGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_GL_TYPE_WINDOW_X11_EGL))
#define GST_GL_WINDOW_X11_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_GL_TYPE_WINDOW_X11_EGL, GstGLWindowX11EGL_Class))
#define GST_GL_TYPE_CONTEXT_COCOA (gst_gl_context_cocoa_get_type())
#define GST_GL_CONTEXT_COCOA(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_GL_TYPE_CONTEXT_COCOA, GstGLContextCocoa))
#define GST_GL_CONTEXT_COCOA_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_GL_TYPE_CONTEXT_COCOA, GstGLContextCocoaClass))
#define GST_GL_IS_CONTEXT_COCOA(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_GL_TYPE_CONTEXT_COCOA))
#define GST_GL_IS_CONTEXT_COCOA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_GL_TYPE_CONTEXT_COCOA))
#define GST_GL_CONTEXT_COCOA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_GL_TYPE_CONTEXT_COCOA, GstGLContextCocoaClass))
typedef struct _GstGLWindowX11EGL GstGLWindowX11EGL;
typedef struct _GstGLWindowX11EGLClass GstGLWindowX11EGLClass;
typedef struct _GstGLContextCocoa GstGLContextCocoa;
typedef struct _GstGLContextCocoaPrivate GstGLContextCocoaPrivate;
typedef struct _GstGLContextCocoaClass GstGLContextCocoaClass;
struct _GstGLWindowX11EGL {
struct _GstGLContextCocoa {
/*< private >*/
GstGLWindowX11 parent;
GstGLEGL *egl;
GstGLContext parent;
/*< private >*/
GstGLContextCocoaPrivate *priv;
gpointer _reserved[GST_PADDING];
};
struct _GstGLWindowX11EGLClass {
struct _GstGLContextCocoaClass {
/*< private >*/
GstGLWindowX11Class parent_class;
GstGLContextClass parent_class;
/*< private >*/
gpointer _reserved[GST_PADDING];
gpointer _reserved[GST_PADDING_LARGE];
GstGLContextCocoaPrivate *priv;
};
GType gst_gl_window_x11_egl_get_type (void);
GType gst_gl_context_cocoa_get_type (void);
GstGLWindowX11EGL * gst_gl_window_x11_egl_new (void);
GstGLContextCocoa * gst_gl_context_cocoa_new (void);
G_END_DECLS
#endif /* __GST_GL_WINDOW_X11_H__ */
#endif /* __GST_GL_CONTEXT_COCOA_H__ */
/*
* GStreamer
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Cocoa/Cocoa.h>
#include "gstglcontext_cocoa.h"
#include "gstgl_cocoa_private.h"
static gboolean gst_gl_context_cocoa_create_context (GstGLContext *context, GstGLAPI gl_api,
guintptr external_opengl_context, GError **error);
static guintptr gst_gl_context_cocoa_get_gl_context (GstGLContext * window);
static gboolean gst_gl_context_cocoa_activate (GstGLContext * context, gboolean activate);
static GstGLAPI gst_gl_context_cocoa_get_gl_api (GstGLContext * context);
#define GST_GL_CONTEXT_COCOA_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_CONTEXT_COCOA, GstGLContextCocoaPrivate))
G_DEFINE_TYPE (GstGLContextCocoa, gst_gl_context_cocoa, GST_GL_TYPE_CONTEXT);
static void
gst_gl_context_cocoa_class_init (GstGLContextCocoaClass * klass)
{
GstGLContextClass *context_class;
#ifndef GNUSTEP
NSAutoreleasePool* pool = nil;
#endif
context_class = (GstGLContextClass *) klass;
g_type_class_add_private (klass, sizeof (GstGLContextCocoaPrivate));
context_class->create_context =
GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_create_context);
context_class->get_gl_context =
GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_get_gl_context);
context_class->activate = GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_activate);
context_class->get_gl_api =
GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_get_gl_api);
#ifndef GNUSTEP
pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
[pool release];
#endif
}
static void
gst_gl_context_cocoa_init (GstGLContextCocoa * context)
{
context->priv = GST_GL_CONTEXT_COCOA_GET_PRIVATE (context);
}
/* Must be called in the gl thread */
GstGLContextCocoa *
gst_gl_context_cocoa_new (void)
{
GstGLContextCocoa *context = g_object_new (GST_GL_TYPE_CONTEXT_COCOA, NULL);
return context;
}
static gboolean
gst_gl_context_cocoa_create_context (GstGLContext *context, GstGLAPI gl_api,
guintptr external_gl_context, GError **error)
{
GstGLContextCocoa *context_cocoa = GST_GL_CONTEXT_COCOA (context);
GstGLContextCocoaPrivate *priv = context_cocoa->priv;
GstGLWindow *window = gst_gl_context_get_window (context);
GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
GstGLNSOpenGLView *glView = nil;
NSWindow *window_handle;
NSRect rect;
NSAutoreleasePool *pool;
NSOpenGLPixelFormat *fmt = nil;
NSOpenGLContext *glContext = nil;
NSOpenGLPixelFormatAttribute attribs[] = {
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccumSize, 32,
0
};
priv->gl_context = nil;
priv->external_gl_context = (NSOpenGLContext *) external_gl_context;
GSRegisterCurrentThread();
pool = [[NSAutoreleasePool alloc] init];
#ifdef GNUSTEP
[NSApplication sharedApplication];
#endif
rect.origin.x = 0;
rect.origin.y = 0;
rect.size.width = 320;
rect.size.height = 240;
priv->rect = rect;
gst_gl_window_cocoa_create_window (window_cocoa);
window_handle = (NSWindow *) gst_gl_window_get_window_handle (window);
glView = [GstGLNSOpenGLView alloc];
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
if (!fmt) {
gst_object_unref (window);
GST_WARNING ("cannot create NSOpenGLPixelFormat");
return FALSE;
}
glView = [glView initWithFrame:window_cocoa rect:rect pixelFormat:fmt];
[window_handle setContentView:glView];
#ifndef GNUSTEP
glContext = [[NSOpenGLContext alloc] initWithFormat:fmt
shareContext:context_cocoa->priv->external_gl_context];
GST_DEBUG ("NSOpenGL context created: %lud\n", (guintptr) glContext);
context_cocoa->priv->gl_context = glContext;
[glView setOpenGLContext:glContext];
#else
context_cocoa->priv->gl_context = [glView openGLContext];
#endif
/* OpenGL context is made current only one time threre.
* Indeed, all OpenGL calls are made in only one thread,
* the Application thread */
[glContext makeCurrentContext];
[glContext update];
/* Back and front buffers are swapped only during the vertical retrace of the monitor.
* Discarded if you configured your driver to Never-use-V-Sync.
*/
NS_DURING {
if (glContext) {
#ifdef GNUSTEP
const long swapInterval = 1;
#else
const GLint swapInterval = 1;
#endif
[[glView openGLContext] setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
}
} NS_HANDLER {
GST_DEBUG ("your back-end does not implement NSOpenglContext::setValues\n");
}
NS_ENDHANDLER
GST_DEBUG ("opengl GstGLNSWindow initialized: %d x %d\n",
(gint) rect.size.width, (gint) rect.size.height);
[pool release];
#ifndef GNUSTEP
priv->source_id = g_timeout_add_seconds (1, gst_gl_window_cocoa_nsapp_iteration, NULL);
#endif
gst_object_unref (window);
return TRUE;
}
static guintptr
gst_gl_context_cocoa_get_gl_context (GstGLContext * context)
{
return (guintptr) GST_GL_CONTEXT_COCOA (context)->priv->gl_context;
}
static gboolean
gst_gl_context_cocoa_activate (GstGLContext * context, gboolean activate)
{
GstGLContextCocoa *context_cocoa;
context_cocoa = GST_GL_CONTEXT_COCOA (context);
if (activate)
[context_cocoa->priv->gl_context makeCurrentContext];
#if 0
else
/* FIXME */
[context_cocoa->priv->gl_context clearCurrentContext];
#endif
return TRUE;
}
static GstGLAPI
gst_gl_context_cocoa_get_gl_api (GstGLContext * context)
{
return GST_GL_API_OPENGL;
}
This diff is collapsed.
......@@ -27,6 +27,19 @@
#include "gl.h"
#include "gstglcontext.h"
#if GST_GL_HAVE_PLATFORM_GLX
#include "x11/gstglcontext_glx.h"
#endif
#if GST_GL_HAVE_PLATFORM_EGL
#include "gstglegl.h"
#endif
#if GST_GL_HAVE_PLATFORM_COCOA
#include "cocoa/gstglcontext_cocoa.h"
#endif
#if GST_GL_HAVE_PLATFORM_WGL
#include "win32/gstglcontext_wgl.h"
#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)
......@@ -37,7 +50,7 @@
GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
#define gst_gl_context_parent_class parent_class
G_DEFINE_TYPE (GstGLContext, gst_gl_context, G_TYPE_OBJECT);
G_DEFINE_ABSTRACT_TYPE (GstGLContext, gst_gl_context, G_TYPE_OBJECT);
#define GST_GL_CONTEXT_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_CONTEXT, GstGLContextPrivate))
......@@ -121,7 +134,6 @@ gst_gl_context_new (GstGLDisplay * display)
user_choice = g_getenv ("GST_GL_PLATFORM");
GST_INFO ("creating a context, user choice:%s", user_choice);
#if 0
#if GST_GL_HAVE_PLATFORM_EGL
if (!context && (!user_choice || g_strstr_len (user_choice, 7, "egl")))
context = GST_GL_CONTEXT (gst_gl_context_egl_new ());
......@@ -130,15 +142,17 @@ gst_gl_context_new (GstGLDisplay * display)
if (!context && (!user_choice || g_strstr_len (user_choice, 3, "glx")))
context = GST_GL_CONTEXT (gst_gl_context_glx_new ());
#endif
#if GST_GL_HAVE_PLATFORM_WIN32
if (!context && (!user_choice || g_strstr_len (user_choice, 5, "win32")))
context = GST_GL_CONTEXT (gst_gl_context_win32_new ());
#endif
#if GST_GL_HAVE_PLATFORM_COCOA
if (!context && (!user_choice || g_strstr_len (user_choice, 5, "cocoa"))) {
context = GST_GL_CONTEXT (gst_gl_context_cocoa_new ());
}
#endif
#if GST_GL_HAVE_PLATFORM_WGL
if (!context && (!user_choice || g_strstr_len (user_choice, 3, "wgl"))) {
context = GST_GL_CONTEXT (gst_gl_context_wgl_new ());
}
#endif
if (!context) {
/* subclass returned a NULL context */
GST_WARNING ("Could not create context. user specified %s",
......@@ -146,9 +160,6 @@ gst_gl_context_new (GstGLDisplay * display)
return NULL;
}
#endif
context = g_object_new (GST_GL_TYPE_CONTEXT, NULL);
context->priv->display = display;
......@@ -164,9 +175,13 @@ gst_gl_context_finalize (GObject * object)
gst_gl_window_set_draw_callback (context->window, NULL, NULL, NULL);
if (context->priv->alive) {
g_mutex_lock (&context->priv->render_lock);
GST_INFO ("send quit gl window loop");
gst_gl_window_quit (context->window);
g_cond_wait (&context->priv->destroy_cond, &context->priv->render_lock);
while (context->priv->alive) {
g_cond_wait (&context->priv->destroy_cond, &context->priv->render_lock);
}
g_mutex_unlock (&context->priv->render_lock);
}
gst_gl_window_set_close_callback (context->window, NULL, NULL, NULL);
......@@ -189,18 +204,17 @@ gst_gl_context_finalize (GObject * object)
G_OBJECT_CLASS (gst_gl_context_parent_class)->finalize (object);
}
/* FIXME move the relevant window vfuncs into GstGLContext */
gboolean
gst_gl_context_activate (GstGLContext * context, gboolean activate)
{
GstGLWindowClass *window_class;
GstGLContextClass *context_class;
gboolean result;
g_return_val_if_fail (GST_GL_IS_CONTEXT (context), FALSE);
window_class = GST_GL_WINDOW_GET_CLASS (context->window);
g_return_val_if_fail (window_class->activate != NULL, FALSE);
context_class = GST_GL_CONTEXT_GET_CLASS (context);
g_return_val_if_fail (context_class->activate != NULL, FALSE);
result = window_class->activate (context->window, activate);
result = context_class->activate (context, activate);
return result;
}
......@@ -208,26 +222,26 @@ gst_gl_context_activate (GstGLContext * context, gboolean activate)
GstGLAPI
gst_gl_context_get_gl_api (GstGLContext * context)
{
GstGLWindowClass *window_class;
GstGLContextClass *context_class;
g_return_val_if_fail (GST_GL_IS_CONTEXT (context), GST_GL_API_NONE);
window_class = GST_GL_WINDOW_GET_CLASS (context->window);
g_return_val_if_fail (window_class->get_gl_api != NULL, GST_GL_API_NONE);
context_class = GST_GL_CONTEXT_GET_CLASS (context);
g_return_val_if_fail (context_class->get_gl_api != NULL, GST_GL_API_NONE);
return window_class->get_gl_api (context->window);
return context_class->get_gl_api (context);
}
gpointer
gst_gl_context_get_proc_address (GstGLContext * context, const gchar * name)
{
gpointer ret;
GstGLWindowClass *window_class;
GstGLContextClass *context_class;
g_return_val_if_fail (GST_GL_IS_CONTEXT (context), NULL);
window_class = GST_GL_WINDOW_GET_CLASS (context->window);
g_return_val_if_fail (window_class->get_proc_address != NULL, NULL);
context_class = GST_GL_CONTEXT_GET_CLASS (context);
g_return_val_if_fail (context_class->get_proc_address != NULL, NULL);
ret = window_class->get_proc_address (context->window, name);
ret = context_class->get_proc_address (context, name);
return ret;
}
......@@ -288,21 +302,13 @@ gst_gl_context_create (GstGLContext * context,
guintptr external_gl_context, GError ** error)
{
gboolean alive = FALSE;
GstGLWindowClass *window_class;
g_return_val_if_fail (GST_GL_IS_CONTEXT (context), FALSE);
window_class = GST_GL_WINDOW_GET_CLASS (context->window);
g_return_val_if_fail (window_class->create_context != NULL, FALSE);
_ensure_window (context);
g_mutex_lock (&context->priv->render_lock);
if (window_class->open) {
if (!(alive = window_class->open (context->window, error)))
goto out;
}
if (!context->priv->created) {
context->priv->external_gl_context = external_gl_context;
context->priv->error = error;
......@@ -321,7 +327,6 @@ gst_gl_context_create (GstGLContext * context,
g_mutex_unlock (&context->priv->render_lock);
out:
return alive;
}
......@@ -475,6 +480,7 @@ _parse_gl_api (const gchar * apis_s)
static gpointer
gst_gl_context_create_thread (GstGLContext * context)
{
GstGLContextClass *context_class;
GstGLWindowClass *window_class;
GstGLDisplay *display;
GstGLFuncs *gl;
......@@ -488,9 +494,12 @@ gst_gl_context_create_thread (GstGLContext * context)
GError **error;
guintptr external_gl_context;
g_mutex_lock (&context->priv->render_lock);
error = context->priv->error;
external_gl_context = context->priv->external_gl_context;
context_class = GST_GL_CONTEXT_GET_CLASS (context);
window_class = GST_GL_WINDOW_GET_CLASS (context->window);
if (window_class->open) {
......@@ -518,17 +527,34 @@ gst_gl_context_create_thread (GstGLContext * context)
goto failure;
}
if (context_class->choose_format &&
!context_class->choose_format (context, error)) {
g_assert (error == NULL || *error != NULL);
g_free (compiled_api_s);
g_free (user_api_string);
goto failure;
}
GST_INFO ("Attempting to create opengl context. user chosen api(s) (%s), "
"compiled api support (%s)", user_api_string, compiled_api_s);
if (!window_class->create_context (context->window, compiled_api & user_api,
if (!context_class->create_context (context, compiled_api & user_api,
external_gl_context, error)) {
g_assert (error == NULL || *error != NULL);
g_free (compiled_api_s);
g_free (user_api_string);
goto failure;
}
GST_INFO ("context created context");
GST_INFO ("created context");
if (!context_class->activate (context, TRUE)) {
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE,
"Failed to activate the GL Context");
g_free (compiled_api_s);
g_free (user_api_string);
goto failure;
}
display->gl_api = gst_gl_context_get_gl_api (context);
g_assert (display->gl_api != GST_GL_API_NONE
......
......@@ -36,7 +36,7 @@ G_BEGIN_DECLS
GType gst_gl_context_get_type (void);
#define GST_GL_CONTEXT_ERROR (gst_gl_context_error_quark ())
GQuark gst_gl_window_error_quark (void);
GQuark gst_gl_context_error_quark (void);
typedef enum
{
......@@ -69,8 +69,11 @@ struct _GstGLContextClass {
GstGLAPI (*get_gl_api) (GstGLContext *context);
gpointer (*get_proc_address) (GstGLContext *context, const gchar *name);
gboolean (*activate) (GstGLContext *context, gboolean activate);
gboolean (*choose_format) (GstGLContext *context, GError **error);
gboolean (*create_context) (GstGLContext *context, GstGLAPI gl_api,
guintptr external_gl_context, GError ** error);
void (*destroy_context) (GstGLContext *context);
void (*swap_buffers) (GstGLContext *context);
/*< private >*/
gpointer _reserved[GST_PADDING];
......
This diff is collapsed.
......@@ -25,12 +25,23 @@
#include <EGL/egl.h>
#include <gst/gl/gstgl_fwd.h>
#include <gst/gl/gstglcontext.h>
G_BEGIN_DECLS
typedef struct _GstGLEGL GstGLEGL;
typedef struct _GstGLContextEGL GstGLContextEGL;
typedef struct _GstGLContextEGLClass GstGLContextEGLClass;
#define GST_GL_TYPE_CONTEXT_EGL (gst_gl_context_egl_get_type())
#define GST_GL_CONTEXT_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_GL_TYPE_CONTEXT_EGL, GstGLContextEGL))
#define GST_GL_CONTEXT_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_GL_TYPE_CONTEXT_EGL, GstGLContextEGLClass))
#define GST_GL_IS_CONTEXT_EGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_GL_TYPE_CONTEXT_EGL))
#define GST_GL_IS_CONTEXT_EGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_GL_TYPE_CONTEXT_EGL))
#define GST_GL_CONTEXT_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_GL_TYPE_CONTEXT_EGL, GstGLContextEGLClass))
struct _GstGLContextEGL {
GstGLContext context;
struct _GstGLEGL {
EGLContext egl_context;
EGLDisplay egl_display;
EGLSurface egl_surface;
......@@ -39,16 +50,12 @@ struct _GstGLEGL {
GstGLAPI gl_api;
};
GstGLEGL * gst_gl_egl_create_context (EGLDisplay display, EGLNativeWindowType window, GstGLAPI gl_api, guintptr external_gl_context, GError ** error);
void gst_gl_egl_destroy_context (GstGLEGL *egl);
gboolean gst_gl_egl_activate (GstGLEGL *egl, gboolean activate);
void gst_gl_egl_swap_buffers (GstGLEGL *egl);
guintptr gst_gl_egl_get_gl_context (GstGLEGL *egl);
GstGLAPI gst_gl_egl_get_gl_api (GstGLEGL *egl);
struct _GstGLContextEGLClass {
GstGLContextClass parent;
};
gpointer gst_gl_egl_get_proc_address (GstGLEGL *egl, const gchar * name);
GType gst_gl_context_egl_get_type (void);
GstGLContextEGL * gst_gl_context_egl_new (void);
G_END_DECLS
......
......@@ -28,6 +28,8 @@
#include "gl.h"
#include "gstglwindow.h"
/* FIXME make this work with windowless contexts */
#if GST_GL_HAVE_WINDOW_X11
#include "x11/gstglwindow_x11.h"
#endif
......@@ -170,40 +172,6 @@ gst_gl_window_finalize (GObject * object)
G_OBJECT_CLASS (gst_gl_window_parent_class)->finalize (object);
}
guintptr
gst_gl_window_get_gl_context (GstGLWindow * window)
{
GstGLWindowClass *window_class;
guintptr result;
g_return_val_if_fail (GST_GL_IS_WINDOW (window), 0);
window_class = GST_GL_WINDOW_GET_CLASS (window);
g_return_val_if_fail (window_class->get_gl_context != NULL, 0);
GST_GL_WINDOW_LOCK (window);
result = window_class->get_gl_context (window);
GST_GL_WINDOW_UNLOCK (window);
return result;
}
gboolean
gst_gl_window_activate (GstGLWindow * window, gboolean activate)
{
GstGLWindowClass *window_class;
gboolean result;
g_return_val_if_fail (GST_GL_IS_WINDOW (window), FALSE);
window_class = GST_GL_WINDOW_GET_CLASS (window);
g_return_val_if_fail (window_class->activate != NULL, FALSE);
GST_GL_WINDOW_LOCK (window);
result = window_class->activate (window, activate);
GST_GL_WINDOW_UNLOCK (window);
return result;
}
void
gst_gl_window_set_window_handle (GstGLWindow * window, guintptr handle)
{
......@@ -369,43 +337,50 @@ gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,