mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
[812/906] move the GL vtable from GstGLDisplay to GstGLContext
Conflicts: tests/check/libs/gstglcontext.c
This commit is contained in:
parent
d139ac89a1
commit
9b22b0e0ba
58 changed files with 824 additions and 858 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -37,15 +37,6 @@ GType gst_gl_display_get_type (void);
|
|||
#define GST_IS_GL_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY))
|
||||
#define GST_GL_DISPLAY_CAST(obj) ((GstGLDisplay*)(obj))
|
||||
|
||||
/**
|
||||
* GstGLDisplayThreadFunc:
|
||||
* @display: a #GstGLDisplay
|
||||
* @data: user data
|
||||
*
|
||||
* Represents a function to run in the GL thread
|
||||
*/
|
||||
typedef void (*GstGLDisplayThreadFunc) (GstGLDisplay * display, gpointer data);
|
||||
|
||||
/**
|
||||
* GstGLDisplay:
|
||||
*
|
||||
|
@ -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);
|
||||
|
|
|
@ -37,29 +37,29 @@
|
|||
* 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)
|
||||
#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 (GstGLDisplay * display, GstGLDownload * download);
|
||||
static void _init_download (GstGLDisplay * display, GstGLDownload * download);
|
||||
static gboolean _init_download_shader (GstGLDisplay * display,
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -65,6 +65,7 @@ struct _GstGLFilter
|
|||
GstBufferPool *pool;
|
||||
|
||||
GstGLDisplay *display;
|
||||
GstGLContext *context;
|
||||
|
||||
GstVideoInfo in_info;
|
||||
GstVideoInfo out_info;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -42,11 +42,11 @@
|
|||
* 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, ©_params);
|
||||
gst_gl_context_thread_add (src->context, _gl_mem_copy_thread, ©_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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -93,6 +93,7 @@ struct _GstGLMixer
|
|||
guint64 qos_processed, qos_dropped;
|
||||
|
||||
GstGLDisplay *display;
|
||||
GstGLContext *context;
|
||||
GLuint fbo;
|
||||
GLuint depthbuffer;
|
||||
};
|
||||
|
|
|
@ -35,11 +35,11 @@
|
|||
#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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -37,26 +37,26 @@
|
|||
* 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)
|
||||
#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 (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);
|
||||
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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -44,11 +44,11 @@
|
|||
#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);
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -29,21 +29,21 @@ gst_gl_effects_bulge_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "bulge0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "bulge0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
bulge_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize bulge shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize bulge shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,21 +29,21 @@ gst_gl_effects_fisheye_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "fisheye0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "fisheye0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
fisheye_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize fisheye shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize fisheye shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,22 +32,22 @@ gst_gl_effects_glow_step_one (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "glow0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "glow0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
luma_threshold_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize luma threshold shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -71,13 +71,13 @@ gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "glow1");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "glow1", shader);
|
||||
}
|
||||
|
||||
|
@ -88,9 +88,9 @@ gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
|
|||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
hconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize hconv7 shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize hconv7 shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -116,21 +116,21 @@ gst_gl_effects_glow_step_three (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "glow2");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "glow2", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
vconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize vcon7 shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize vcon7 shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -156,21 +156,21 @@ gst_gl_effects_glow_step_four (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "glow3");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "glow3", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
sum_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize sum shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize sum shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
|
||||
#include "../gstgleffects.h"
|
||||
|
||||
#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)
|
||||
|
||||
static void
|
||||
gst_gl_effects_identity_callback (gint width, gint height, guint texture,
|
||||
|
@ -35,22 +35,22 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLFilter *filter = GST_GL_FILTER (effects);
|
||||
GstGLDisplay *display = filter->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = filter->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (display)) {
|
||||
if (USING_OPENGL (context)) {
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
}
|
||||
#endif
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (USING_GLES2 (display)) {
|
||||
if (USING_GLES2 (context)) {
|
||||
GstGLShader *shader =
|
||||
g_hash_table_lookup (effects->shaderstable, "identity0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "identity0", shader);
|
||||
|
||||
if (shader) {
|
||||
|
|
|
@ -30,22 +30,22 @@ gst_gl_effects_luma_to_curve (GstGLEffects * effects,
|
|||
gint curve_index, gint width, gint height, GLuint texture)
|
||||
{
|
||||
GstGLShader *shader;
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "lumamap0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "lumamap0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
luma_to_curve_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize luma to curve shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
|
||||
#include "../gstgleffects.h"
|
||||
|
||||
#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)
|
||||
|
||||
static void
|
||||
gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
|
||||
|
@ -36,17 +36,17 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
|
|||
GstGLShader *shader;
|
||||
GstGLFilter *filter = GST_GL_FILTER (data);
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (filter);
|
||||
GstGLDisplay *display = filter->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = filter->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "mirror0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "mirror0", shader);
|
||||
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (USING_GLES2 (display)) {
|
||||
if (USING_GLES2 (context)) {
|
||||
if (shader) {
|
||||
GError *error = NULL;
|
||||
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
|
||||
|
@ -55,13 +55,13 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
|
|||
|
||||
gst_gl_shader_compile (shader, &error);
|
||||
if (error) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize mirror shader, %s", error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
gst_gl_shader_use (NULL);
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
} else {
|
||||
effects->draw_attr_position_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
|
@ -72,13 +72,13 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
|
|||
}
|
||||
#endif
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (display)) {
|
||||
if (USING_OPENGL (context)) {
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
mirror_fragment_source_opengl, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize mirror shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
|
|||
#endif
|
||||
}
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (display)) {
|
||||
if (USING_OPENGL (context)) {
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (filter->display)) {
|
||||
if (USING_OPENGL (filter->context)) {
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
|
||||
}
|
||||
|
|
|
@ -30,22 +30,22 @@ gst_gl_effects_rgb_to_curve (GstGLEffects * effects,
|
|||
gint curve_index, gint width, gint height, GLuint texture)
|
||||
{
|
||||
GstGLShader *shader;
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "rgbmap0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "rgbmap0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
rgb_to_curve_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize rgb to curve shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,21 +29,21 @@ gst_gl_effects_sin_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "sin0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "sin0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
sin_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize sin shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize sin shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,21 +29,21 @@ gst_gl_effects_square_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "square0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "square0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
square_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize square shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize square shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
|
||||
#include "../gstgleffects.h"
|
||||
|
||||
#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)
|
||||
|
||||
static void
|
||||
gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
|
||||
|
@ -36,17 +36,17 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
|
|||
GstGLShader *shader;
|
||||
GstGLFilter *filter = GST_GL_FILTER (data);
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = filter->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = filter->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "squeeze0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "squeeze0", shader);
|
||||
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (USING_GLES2 (display)) {
|
||||
if (USING_GLES2 (context)) {
|
||||
if (shader) {
|
||||
GError *error = NULL;
|
||||
gst_gl_shader_set_vertex_source (shader, vertex_shader_source);
|
||||
|
@ -55,13 +55,13 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
|
|||
|
||||
gst_gl_shader_compile (shader, &error);
|
||||
if (error) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize squeeze shader, %s", error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
gst_gl_shader_use (NULL);
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
} else {
|
||||
effects->draw_attr_position_loc =
|
||||
gst_gl_shader_get_attribute_location (shader, "a_position");
|
||||
|
@ -72,20 +72,20 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
|
|||
}
|
||||
#endif
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (display)) {
|
||||
if (USING_OPENGL (context)) {
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
squeeze_fragment_source_opengl, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize squeeze shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (display)) {
|
||||
if (USING_OPENGL (context)) {
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ gst_gl_effects_squeeze_callback (gint width, gint height, guint texture,
|
|||
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
|
||||
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (filter->display)) {
|
||||
if (USING_OPENGL (filter->context)) {
|
||||
gst_gl_shader_set_uniform_1f (shader, "width", (gfloat) width / 2.0f);
|
||||
gst_gl_shader_set_uniform_1f (shader, "height", (gfloat) height / 2.0f);
|
||||
}
|
||||
|
|
|
@ -29,21 +29,21 @@ gst_gl_effects_stretch_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "stretch0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "stretch0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
stretch_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize stretch shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize stretch shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,21 +29,21 @@ gst_gl_effects_tunnel_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "tunnel0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "tunnel0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
tunnel_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize tunnel shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize tunnel shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,21 +29,21 @@ gst_gl_effects_twirl_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "twirl0");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->display);
|
||||
shader = gst_gl_shader_new (GST_GL_FILTER (effects)->context);
|
||||
g_hash_table_insert (effects->shaderstable, "twirl0", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
twirl_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize twirl shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize twirl shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,13 +44,13 @@ gst_gl_effects_xray_step_two (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "xray1");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "xray1", shader);
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,9 @@ gst_gl_effects_xray_step_two (gint width, gint height, guint texture,
|
|||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
hconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize hconv7 shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize hconv7 shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -89,21 +89,21 @@ gst_gl_effects_xray_step_three (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "xray2");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "xray2", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
vconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize vconv7 shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize vconv7 shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -130,22 +130,22 @@ gst_gl_effects_xray_desaturate (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "xray_desat");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "xray_desat", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
desaturate_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize desaturate shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -169,22 +169,22 @@ gst_gl_effects_xray_sobel_hconv (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_hconv");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "xray_sob_hconv", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
sep_sobel_hconv3_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize sobel hvonc3 shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -208,22 +208,22 @@ gst_gl_effects_xray_sobel_vconv (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_vconv");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "xray_sob_vconv", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
sep_sobel_vconv3_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize sobel vconv3 shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -247,22 +247,22 @@ gst_gl_effects_xray_sobel_length (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "xray_sob_len");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "xray_sob_len", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
sep_sobel_length_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display,
|
||||
gst_gl_context_set_error (context,
|
||||
"Failed to initialize seobel length shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -289,21 +289,21 @@ gst_gl_effects_xray_step_five (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLShader *shader;
|
||||
GstGLEffects *effects = GST_GL_EFFECTS (data);
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
shader = g_hash_table_lookup (effects->shaderstable, "xray4");
|
||||
|
||||
if (!shader) {
|
||||
shader = gst_gl_shader_new (display);
|
||||
shader = gst_gl_shader_new (context);
|
||||
g_hash_table_insert (effects->shaderstable, "xray4", shader);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (shader,
|
||||
multiply_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (display, "Failed to initialize multiply shader");
|
||||
gst_gl_context_set_error (context, "Failed to initialize multiply shader");
|
||||
GST_ELEMENT_ERROR (effects, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ static const gchar *bumper_f_src =
|
|||
" gl_FragColor = vec4(irradiance * textureColor.rgb, textureColor.w);\n"
|
||||
"}\n";
|
||||
|
||||
#define LOAD_ERROR(display, msg) { gst_gl_display_set_error (display, "unable to load %s: %s", bumper->location, msg); return; }
|
||||
#define LOAD_ERROR(context, msg) { gst_gl_context_set_error (context, "unable to load %s: %s", bumper->location, msg); return; }
|
||||
|
||||
//png reading error handler
|
||||
static void
|
||||
|
@ -153,7 +153,7 @@ static void
|
|||
gst_gl_bumper_init_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLBumper *bumper = GST_GL_BUMPER (filter);
|
||||
GstGLDisplay *display = filter->display;
|
||||
GstGLContext *context = filter->context;
|
||||
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
|
@ -169,37 +169,37 @@ gst_gl_bumper_init_resources (GstGLFilter * filter)
|
|||
png_byte magic[8];
|
||||
gint n_read;
|
||||
|
||||
if (!display)
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
if (!bumper->location) {
|
||||
gst_gl_display_set_error (display, "A filename is required");
|
||||
gst_gl_context_set_error (context, "A filename is required");
|
||||
return;
|
||||
}
|
||||
|
||||
/* BEGIN load png image file */
|
||||
|
||||
if ((fp = fopen (bumper->location, "rb")) == NULL)
|
||||
LOAD_ERROR (display, "file not found");
|
||||
LOAD_ERROR (context, "file not found");
|
||||
|
||||
/* Read magic number */
|
||||
n_read = fread (magic, 1, sizeof (magic), fp);
|
||||
if (n_read != sizeof (magic)) {
|
||||
fclose (fp);
|
||||
LOAD_ERROR (display, "can't read PNG magic number");
|
||||
LOAD_ERROR (context, "can't read PNG magic number");
|
||||
}
|
||||
|
||||
/* Check for valid magic number */
|
||||
if (png_sig_cmp (magic, 0, sizeof (magic))) {
|
||||
fclose (fp);
|
||||
LOAD_ERROR (display, "not a valid PNG image");
|
||||
LOAD_ERROR (context, "not a valid PNG image");
|
||||
}
|
||||
|
||||
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
|
||||
if (png_ptr == NULL) {
|
||||
fclose (fp);
|
||||
LOAD_ERROR (display, "failed to initialize the png_struct");
|
||||
LOAD_ERROR (context, "failed to initialize the png_struct");
|
||||
}
|
||||
|
||||
png_set_error_fn (png_ptr, NULL, NULL, user_warning_fn);
|
||||
|
@ -208,7 +208,7 @@ gst_gl_bumper_init_resources (GstGLFilter * filter)
|
|||
if (info_ptr == NULL) {
|
||||
fclose (fp);
|
||||
png_destroy_read_struct (&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
LOAD_ERROR (display,
|
||||
LOAD_ERROR (context,
|
||||
"failed to initialize the memory for image information");
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ gst_gl_bumper_init_resources (GstGLFilter * filter)
|
|||
if (color_type != PNG_COLOR_TYPE_RGB) {
|
||||
fclose (fp);
|
||||
png_destroy_read_struct (&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
LOAD_ERROR (display, "color type is not rgb");
|
||||
LOAD_ERROR (context, "color type is not rgb");
|
||||
}
|
||||
|
||||
raw_data = (guchar *) malloc (sizeof (guchar) * width * height * 3);
|
||||
|
@ -313,7 +313,7 @@ gst_gl_bumper_reset (GstGLFilter * filter)
|
|||
GstGLBumper *bumper_filter = GST_GL_BUMPER (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, bumper_filter->shader);
|
||||
gst_gl_context_del_shader (filter->context, bumper_filter->shader);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -356,7 +356,7 @@ gst_gl_bumper_init_shader (GstGLFilter * filter)
|
|||
GstGLBumper *bumper = GST_GL_BUMPER (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
return gst_gl_display_gen_shader (filter->display, bumper_v_src, bumper_f_src,
|
||||
return gst_gl_context_gen_shader (filter->context, bumper_v_src, bumper_f_src,
|
||||
&bumper->shader);
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ gst_gl_bumper_filter_texture (GstGLFilter * filter, guint in_tex, guint out_tex)
|
|||
gpointer bumper_filter = GST_GL_BUMPER (filter);
|
||||
|
||||
//blocking call, use a FBO
|
||||
gst_gl_display_use_fbo (filter->display,
|
||||
gst_gl_context_use_fbo (filter->context,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer, out_tex, gst_gl_bumper_callback,
|
||||
|
@ -399,7 +399,7 @@ gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
|
|||
|
||||
GstGLFuncs *gl;
|
||||
GstGLBumper *bumper = GST_GL_BUMPER (stuff);
|
||||
GstGLDisplay *display = GST_GL_FILTER (bumper)->display;
|
||||
GstGLContext *context = GST_GL_FILTER (bumper)->context;
|
||||
GLint locTangent = 0;
|
||||
|
||||
//choose the lights
|
||||
|
@ -462,7 +462,7 @@ gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
|
|||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
gl = GST_GL_FILTER (bumper)->display->gl_vtable;
|
||||
gl = GST_GL_FILTER (bumper)->context->gl_vtable;
|
||||
|
||||
//eye point
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
|
@ -534,7 +534,7 @@ gst_gl_bumper_callback (gint width, gint height, guint texture, gpointer stuff)
|
|||
|
||||
gl->DisableVertexAttribArray (locTangent);
|
||||
|
||||
gst_gl_display_clear_shader (display);
|
||||
gst_gl_context_clear_shader (context);
|
||||
|
||||
gl->Disable (GL_LIGHT0);
|
||||
gl->Disable (GL_LIGHT1);
|
||||
|
|
|
@ -189,7 +189,7 @@ gst_gl_deinterlace_reset (GstGLFilter * filter)
|
|||
deinterlace_filter->prev_buffer = NULL;
|
||||
}
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, deinterlace_filter->shader);
|
||||
gst_gl_context_del_shader (filter->context, deinterlace_filter->shader);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -224,7 +224,7 @@ gst_gl_deinterlace_init_shader (GstGLFilter * filter)
|
|||
GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
return gst_gl_display_gen_shader (filter->display, 0, greedyh_fragment_source,
|
||||
return gst_gl_context_gen_shader (filter->context, 0, greedyh_fragment_source,
|
||||
&deinterlace_filter->shader);
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (stuff);
|
||||
GstGLFilter *filter = GST_GL_FILTER (stuff);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
guint temp;
|
||||
|
||||
GLfloat verts[] = { -1.0, -1.0,
|
||||
|
@ -291,7 +291,7 @@ gst_gl_deinterlace_callback (gint width, gint height, guint texture,
|
|||
gl->Enable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
|
||||
if (G_UNLIKELY (deinterlace_filter->prev_tex == 0)) {
|
||||
gst_gl_display_gen_texture_thread (filter->display,
|
||||
gst_gl_context_gen_texture_thread (filter->context,
|
||||
&deinterlace_filter->prev_tex,
|
||||
GST_VIDEO_INFO_FORMAT (&filter->out_info),
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
|
|
|
@ -81,7 +81,7 @@ static void
|
|||
gst_gl_differencematte_init_gl_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
|
@ -99,42 +99,42 @@ gst_gl_differencematte_init_gl_resources (GstGLFilter * filter)
|
|||
GL_CLAMP_TO_EDGE);
|
||||
gl->TexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
differencematte->shader[i] = gst_gl_shader_new (filter->display);
|
||||
differencematte->shader[i] = gst_gl_shader_new (filter->context);
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (differencematte->shader[0],
|
||||
difference_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (differencematte)->display,
|
||||
gst_gl_context_set_error (GST_GL_FILTER (differencematte)->context,
|
||||
"Failed to initialize difference shader");
|
||||
GST_ELEMENT_ERROR (differencematte, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (differencematte->shader[1],
|
||||
hconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (differencematte)->display,
|
||||
gst_gl_context_set_error (GST_GL_FILTER (differencematte)->context,
|
||||
"Failed to initialize hconv7 shader");
|
||||
GST_ELEMENT_ERROR (differencematte, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (differencematte->shader[2],
|
||||
vconv7_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (differencematte)->display,
|
||||
gst_gl_context_set_error (GST_GL_FILTER (differencematte)->context,
|
||||
"Failed to initialize vconv7 shader");
|
||||
GST_ELEMENT_ERROR (differencematte, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gst_gl_shader_compile_and_check (differencematte->shader[3],
|
||||
texture_interp_fragment_source, GST_GL_SHADER_FRAGMENT_SOURCE)) {
|
||||
gst_gl_display_set_error (GST_GL_FILTER (differencematte)->display,
|
||||
gst_gl_context_set_error (GST_GL_FILTER (differencematte)->context,
|
||||
"Failed to initialize interp shader");
|
||||
GST_ELEMENT_ERROR (differencematte, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ static void
|
|||
gst_gl_differencematte_reset_gl_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
gint i;
|
||||
|
||||
gl->DeleteTextures (1, &differencematte->savedbgtexture);
|
||||
|
@ -267,7 +267,7 @@ gst_gl_differencematte_save_texture (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 ();
|
||||
|
@ -276,11 +276,11 @@ gst_gl_differencematte_save_texture (gint width, gint height, guint texture,
|
|||
}
|
||||
|
||||
static void
|
||||
init_pixbuf_texture (GstGLDisplay * display, gpointer data)
|
||||
init_pixbuf_texture (GstGLContext * context, gpointer data)
|
||||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (data);
|
||||
GstGLFilter *filter = GST_GL_FILTER (data);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->DeleteTextures (1, &differencematte->newbgtexture);
|
||||
gl->GenTextures (1, &differencematte->newbgtexture);
|
||||
|
@ -313,7 +313,7 @@ gst_gl_differencematte_diff (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (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 ();
|
||||
|
@ -343,7 +343,7 @@ gst_gl_differencematte_hblur (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (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 ();
|
||||
|
@ -369,7 +369,7 @@ gst_gl_differencematte_vblur (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (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 ();
|
||||
|
@ -395,7 +395,7 @@ gst_gl_differencematte_interp (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (stuff);
|
||||
GstGLFilter *filter = GST_GL_FILTER (stuff);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
|
@ -441,7 +441,7 @@ gst_gl_differencematte_identity (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (stuff);
|
||||
GstGLFilter *filter = GST_GL_FILTER (differencematte);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
|
@ -462,8 +462,8 @@ gst_gl_differencematte_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
if (!gst_gl_differencematte_loader (filter))
|
||||
differencematte->pixbuf = NULL;
|
||||
|
||||
/* if loader failed then display is turned off */
|
||||
gst_gl_display_thread_add (filter->display, init_pixbuf_texture,
|
||||
/* if loader failed then context is turned off */
|
||||
gst_gl_context_thread_add (filter->context, init_pixbuf_texture,
|
||||
differencematte);
|
||||
|
||||
/* save current frame, needed to calculate difference between
|
||||
|
@ -526,7 +526,7 @@ gst_gl_differencematte_loader (GstGLFilter * filter)
|
|||
guchar **rows = NULL;
|
||||
gint filler;
|
||||
|
||||
if (!filter->display)
|
||||
if (!filter->context)
|
||||
return TRUE;
|
||||
|
||||
if ((fp = fopen (differencematte->location, "rb")) == NULL)
|
||||
|
|
|
@ -275,11 +275,11 @@ void
|
|||
gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex, guint width,
|
||||
guint height)
|
||||
{
|
||||
GstGLDisplay *display = GST_GL_FILTER (effects)->display;
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLContext *context = GST_GL_FILTER (effects)->context;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL) {
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
|
||||
GLfloat verts[] = { -1.0f, -1.0f,
|
||||
1.0f, -1.0f,
|
||||
1.0f, 1.0f,
|
||||
|
@ -309,7 +309,7 @@ gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex, guint width,
|
|||
}
|
||||
#endif
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES2) {
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) {
|
||||
const GLfloat vVertices[] = {
|
||||
-1.0f, -1.0f, 0.0f,
|
||||
0.0f, 0.0f,
|
||||
|
@ -337,16 +337,16 @@ gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex, guint width,
|
|||
}
|
||||
#endif
|
||||
|
||||
gst_gl_display_clear_shader (display);
|
||||
gst_gl_context_clear_shader (context);
|
||||
}
|
||||
|
||||
static void
|
||||
set_horizontal_swap (GstGLDisplay * display, gpointer data)
|
||||
set_horizontal_swap (GstGLContext * context, gpointer data)
|
||||
{
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
GstGLFuncs *gl = display->gl_vtable;
|
||||
GstGLFuncs *gl = context->gl_vtable;
|
||||
|
||||
if (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL) {
|
||||
if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
|
||||
const gfloat mirrormatrix[16] = {
|
||||
-1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0
|
||||
|
@ -372,7 +372,7 @@ gst_gl_effects_ghash_func_clean (gpointer key, gpointer value, gpointer data)
|
|||
GstGLFilter *filter = (GstGLFilter *) data;
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, shader);
|
||||
gst_gl_context_del_shader (filter->context, shader);
|
||||
|
||||
value = NULL;
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ gst_gl_effects_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
effects->outtexture = out_tex;
|
||||
|
||||
if (effects->horizontal_swap == TRUE)
|
||||
gst_gl_display_thread_add (filter->display, set_horizontal_swap, effects);
|
||||
gst_gl_context_thread_add (filter->context, set_horizontal_swap, effects);
|
||||
|
||||
effects->effect (effects);
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ gst_gl_filter_app_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
|
||||
if (app_filter->clientDrawCallback) {
|
||||
//blocking call, use a FBO
|
||||
gst_gl_display_use_fbo (filter->display,
|
||||
gst_gl_context_use_fbo (filter->context,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer, out_tex,
|
||||
|
@ -205,7 +205,7 @@ gst_gl_filter_app_callback (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 ();
|
||||
|
|
|
@ -67,7 +67,7 @@ static void
|
|||
gst_gl_filterblur_init_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->GenTextures (1, &filterblur->midtexture);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, filterblur->midtexture);
|
||||
|
@ -89,7 +89,7 @@ static void
|
|||
gst_gl_filterblur_reset_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->DeleteTextures (1, &filterblur->midtexture);
|
||||
}
|
||||
|
@ -138,10 +138,10 @@ gst_gl_filter_filterblur_reset (GstGLFilter * filter)
|
|||
GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, filterblur->shader0);
|
||||
gst_gl_context_del_shader (filter->context, filterblur->shader0);
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, filterblur->shader1);
|
||||
gst_gl_context_del_shader (filter->context, filterblur->shader1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -176,12 +176,12 @@ gst_gl_filterblur_init_shader (GstGLFilter * filter)
|
|||
GstGLFilterBlur *blur_filter = GST_GL_FILTERBLUR (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
if (!gst_gl_display_gen_shader (filter->display, 0, hconv7_fragment_source,
|
||||
if (!gst_gl_context_gen_shader (filter->context, 0, hconv7_fragment_source,
|
||||
&blur_filter->shader0))
|
||||
return FALSE;
|
||||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
if (!gst_gl_display_gen_shader (filter->display, 0, vconv7_fragment_source,
|
||||
if (!gst_gl_context_gen_shader (filter->context, 0, vconv7_fragment_source,
|
||||
&blur_filter->shader1))
|
||||
return FALSE;
|
||||
|
||||
|
@ -209,7 +209,7 @@ gst_gl_filterblur_hcallback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (stuff);
|
||||
GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
|
@ -235,7 +235,7 @@ gst_gl_filterblur_vcallback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (stuff);
|
||||
GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
|
|
|
@ -287,7 +287,7 @@ gst_gl_filter_cube_reset (GstGLFilter * filter)
|
|||
|
||||
/* blocking call, wait the opengl thread has destroyed the shader */
|
||||
if (cube_filter->shader)
|
||||
gst_gl_display_del_shader (filter->display, cube_filter->shader);
|
||||
gst_gl_context_del_shader (filter->context, cube_filter->shader);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -295,9 +295,9 @@ gst_gl_filter_cube_init_shader (GstGLFilter * filter)
|
|||
{
|
||||
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
|
||||
|
||||
if (gst_gl_display_get_gl_api (filter->display) & GST_GL_API_GLES2) {
|
||||
if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_GLES2) {
|
||||
/* blocking call, wait the opengl thread has compiled the shader */
|
||||
return gst_gl_display_gen_shader (filter->display, cube_v_src, cube_f_src,
|
||||
return gst_gl_context_gen_shader (filter->context, cube_v_src, cube_f_src,
|
||||
&cube_filter->shader);
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -312,7 +312,7 @@ gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
GLCB cb = NULL;
|
||||
GstGLAPI api;
|
||||
|
||||
api = gst_gl_display_get_gl_api (GST_GL_FILTER (cube_filter)->display);
|
||||
api = gst_gl_context_get_gl_api (GST_GL_FILTER (cube_filter)->context);
|
||||
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (api & GST_GL_API_OPENGL)
|
||||
|
@ -324,7 +324,7 @@ gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
#endif
|
||||
|
||||
/* blocking call, use a FBO */
|
||||
gst_gl_display_use_fbo (filter->display,
|
||||
gst_gl_context_use_fbo (filter->context,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer, out_tex,
|
||||
|
@ -345,7 +345,7 @@ _callback_opengl (gint width, gint height, guint texture, gpointer stuff)
|
|||
{
|
||||
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (stuff);
|
||||
GstGLFilter *filter = GST_GL_FILTER (stuff);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
static GLfloat xrot = 0;
|
||||
static GLfloat yrot = 0;
|
||||
|
@ -450,7 +450,7 @@ _callback_gles2 (gint width, gint height, guint texture, gpointer stuff)
|
|||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (stuff);
|
||||
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
static GLfloat xrot = 0;
|
||||
static GLfloat yrot = 0;
|
||||
|
|
|
@ -180,8 +180,8 @@ gst_gl_filter_glass_reset (GstGLFilter * filter)
|
|||
GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, glass_filter->shader);
|
||||
gst_gl_display_del_shader (filter->display, glass_filter->passthrough_shader);
|
||||
gst_gl_context_del_shader (filter->context, glass_filter->shader);
|
||||
gst_gl_context_del_shader (filter->context, glass_filter->passthrough_shader);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -218,11 +218,11 @@ gst_gl_filter_glass_init_shader (GstGLFilter * filter)
|
|||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
ret =
|
||||
gst_gl_display_gen_shader (filter->display, glass_vertex_source,
|
||||
gst_gl_context_gen_shader (filter->context, glass_vertex_source,
|
||||
glass_fragment_source, &glass_filter->shader);
|
||||
if (ret)
|
||||
ret =
|
||||
gst_gl_display_gen_shader (filter->display, passthrough_vertex,
|
||||
gst_gl_context_gen_shader (filter->context, passthrough_vertex,
|
||||
passthrough_fragment, &glass_filter->passthrough_shader);
|
||||
|
||||
return ret;
|
||||
|
@ -236,7 +236,7 @@ gst_gl_filter_glass_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
glass_filter->in_tex = in_tex;
|
||||
|
||||
//blocking call, use a FBO
|
||||
gst_gl_display_use_fbo_v2 (filter->display,
|
||||
gst_gl_context_use_fbo_v2 (filter->context,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer, out_tex,
|
||||
|
@ -258,7 +258,7 @@ static void
|
|||
gst_gl_filter_glass_draw_background_gradient (GstGLFilterGlass * glass)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (glass);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
gfloat mesh[] = {
|
||||
|
@ -299,7 +299,7 @@ gst_gl_filter_glass_draw_video_plane (GstGLFilter * filter,
|
|||
gfloat start_alpha, gfloat stop_alpha, gboolean reversed, gfloat rotation)
|
||||
{
|
||||
GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gfloat w = (gfloat) width;
|
||||
gfloat h = (gfloat) height;
|
||||
|
@ -357,7 +357,7 @@ gst_gl_filter_glass_callback (gpointer stuff)
|
|||
|
||||
GstGLFilter *filter = GST_GL_FILTER (stuff);
|
||||
GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (stuff);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gint width = GST_VIDEO_INFO_WIDTH (&filter->out_info);
|
||||
gint height = GST_VIDEO_INFO_HEIGHT (&filter->out_info);
|
||||
|
@ -400,7 +400,7 @@ gst_gl_filter_glass_callback (gpointer stuff)
|
|||
gst_gl_filter_glass_draw_video_plane (filter, width, height, texture,
|
||||
0.0f, 0.0f, 1.0f, 1.0f, FALSE, rotation);
|
||||
|
||||
gst_gl_display_clear_shader (filter->display);
|
||||
gst_gl_context_clear_shader (filter->context);
|
||||
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
gl->Disable (GL_BLEND);
|
||||
|
|
|
@ -131,7 +131,7 @@ gst_gl_filter_laplacian_reset (GstGLFilter * filter)
|
|||
GstGLFilterLaplacian *laplacian_filter = GST_GL_FILTER_LAPLACIAN (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, laplacian_filter->shader);
|
||||
gst_gl_context_del_shader (filter->context, laplacian_filter->shader);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -166,7 +166,7 @@ gst_gl_filter_laplacian_init_shader (GstGLFilter * filter)
|
|||
GstGLFilterLaplacian *laplacian_filter = GST_GL_FILTER_LAPLACIAN (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
return gst_gl_display_gen_shader (filter->display, 0,
|
||||
return gst_gl_context_gen_shader (filter->context, 0,
|
||||
convolution_fragment_source, &laplacian_filter->shader);
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ gst_gl_filter_laplacian_callback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (stuff);
|
||||
GstGLFilterLaplacian *laplacian_filter = GST_GL_FILTER_LAPLACIAN (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gfloat kernel[9] = { 0.0, -1.0, 0.0,
|
||||
-1.0, 4.0, -1.0,
|
||||
|
|
|
@ -228,7 +228,7 @@ gst_gl_filter_reflected_screen_filter_texture (GstGLFilter * filter,
|
|||
GST_GL_FILTER_REFLECTED_SCREEN (filter);
|
||||
|
||||
//blocking call, use a FBO
|
||||
gst_gl_display_use_fbo (filter->display,
|
||||
gst_gl_context_use_fbo (filter->context,
|
||||
GST_VIDEO_INFO_WIDTH (&filter->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
||||
filter->fbo, filter->depthbuffer, out_tex,
|
||||
|
|
|
@ -160,7 +160,7 @@ gst_gl_filter_filtershader_reset (GstGLFilter * filter)
|
|||
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, filtershader->shader0);
|
||||
gst_gl_context_del_shader (filter->context, filtershader->shader0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ gst_gl_filtershader_set_property (GObject * object, guint prop_id,
|
|||
g_free (filtershader->filename);
|
||||
}
|
||||
if (filtershader->compiled) {
|
||||
//gst_gl_display_del_shader (filtershader->filter.display, filtershader->shader0);
|
||||
//gst_gl_context_del_shader (filtershader->filter.context, filtershader->shader0);
|
||||
gst_gl_filter_filtershader_reset (&filtershader->filter);
|
||||
filtershader->shader0 = 0;
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ gst_gl_filtershader_init_shader (GstGLFilter * filter)
|
|||
return FALSE;
|
||||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
if (!gst_gl_display_gen_shader (filter->display, 0, hfilter_fragment_source,
|
||||
if (!gst_gl_context_gen_shader (filter->context, 0, hfilter_fragment_source,
|
||||
&filtershader->shader0))
|
||||
return FALSE;
|
||||
|
||||
|
@ -351,7 +351,7 @@ gst_gl_filtershader_hcallback (gint width, gint height, guint texture,
|
|||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (stuff);
|
||||
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
|
|
|
@ -71,7 +71,7 @@ static void
|
|||
gst_gl_filtersobel_init_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
|
@ -96,7 +96,7 @@ static void
|
|||
gst_gl_filtersobel_reset_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter);
|
||||
GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
|
@ -155,10 +155,10 @@ gst_gl_filter_filtersobel_reset (GstGLFilter * filter)
|
|||
GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter);
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (filter->display, filtersobel->desat);
|
||||
gst_gl_display_del_shader (filter->display, filtersobel->hconv);
|
||||
gst_gl_display_del_shader (filter->display, filtersobel->vconv);
|
||||
gst_gl_display_del_shader (filter->display, filtersobel->len);
|
||||
gst_gl_context_del_shader (filter->context, filtersobel->desat);
|
||||
gst_gl_context_del_shader (filter->context, filtersobel->hconv);
|
||||
gst_gl_context_del_shader (filter->context, filtersobel->vconv);
|
||||
gst_gl_context_del_shader (filter->context, filtersobel->len);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -201,16 +201,16 @@ gst_gl_filtersobel_init_shader (GstGLFilter * filter)
|
|||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
ret =
|
||||
gst_gl_display_gen_shader (filter->display, 0, desaturate_fragment_source,
|
||||
gst_gl_context_gen_shader (filter->context, 0, desaturate_fragment_source,
|
||||
&filtersobel->desat);
|
||||
ret &=
|
||||
gst_gl_display_gen_shader (filter->display, 0,
|
||||
gst_gl_context_gen_shader (filter->context, 0,
|
||||
sep_sobel_hconv3_fragment_source, &filtersobel->hconv);
|
||||
ret &=
|
||||
gst_gl_display_gen_shader (filter->display, 0,
|
||||
gst_gl_context_gen_shader (filter->context, 0,
|
||||
sep_sobel_vconv3_fragment_source, &filtersobel->vconv);
|
||||
ret &=
|
||||
gst_gl_display_gen_shader (filter->display, 0,
|
||||
gst_gl_context_gen_shader (filter->context, 0,
|
||||
sep_sobel_length_fragment_source, &filtersobel->len);
|
||||
|
||||
return ret;
|
||||
|
@ -241,7 +241,7 @@ gst_gl_filtersobel_length (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;
|
||||
GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter);
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
|
|
|
@ -97,11 +97,11 @@ GST_DEBUG_CATEGORY (gst_debug_glimage_sink);
|
|||
#define GST_GLIMAGE_SINK_UNLOCK(glsink) \
|
||||
(g_mutex_unlock(&GST_GLIMAGE_SINK_GET_LOCK (glsink)))
|
||||
|
||||
#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)
|
||||
|
||||
#if GST_GL_HAVE_GLES2
|
||||
static void gst_glimage_sink_thread_init_redisplay (GstGLImageSink * gl_sink);
|
||||
|
@ -426,14 +426,14 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
|
|||
g_atomic_int_set (&glimage_sink->to_quit, 0);
|
||||
if (!glimage_sink->display) {
|
||||
GstGLWindow *window;
|
||||
GstGLContext *context;
|
||||
GError *error = NULL;
|
||||
|
||||
GST_INFO ("Creating GstGLDisplay");
|
||||
glimage_sink->display = gst_gl_display_new ();
|
||||
context = gst_gl_context_new (glimage_sink->display);
|
||||
gst_gl_display_set_context (glimage_sink->display, context);
|
||||
window = gst_gl_context_get_window (context);
|
||||
glimage_sink->context = gst_gl_context_new (glimage_sink->display);
|
||||
gst_gl_display_set_context (glimage_sink->display,
|
||||
glimage_sink->context);
|
||||
window = gst_gl_context_get_window (glimage_sink->context);
|
||||
|
||||
if (!glimage_sink->window_id && !glimage_sink->new_window_id)
|
||||
gst_video_overlay_prepare_window_handle (GST_VIDEO_OVERLAY
|
||||
|
@ -444,7 +444,7 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
|
|||
gst_gl_window_set_window_handle (window, glimage_sink->window_id);
|
||||
}
|
||||
|
||||
if (!gst_gl_context_create (context, 0, &error)) {
|
||||
if (!gst_gl_context_create (glimage_sink->context, 0, &error)) {
|
||||
GST_ELEMENT_ERROR (glimage_sink, RESOURCE, NOT_FOUND,
|
||||
("%s", error->message), (NULL));
|
||||
|
||||
|
@ -452,7 +452,7 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
|
|||
gst_object_unref (glimage_sink->display);
|
||||
glimage_sink->display = NULL;
|
||||
}
|
||||
gst_object_unref (context);
|
||||
gst_object_unref (glimage_sink->context);
|
||||
|
||||
return GST_STATE_CHANGE_FAILURE;
|
||||
}
|
||||
|
@ -469,7 +469,6 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
|
|||
gst_object_ref (glimage_sink), (GDestroyNotify) gst_object_unref);
|
||||
|
||||
gst_object_unref (window);
|
||||
gst_object_unref (context);
|
||||
}
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
|
@ -514,10 +513,8 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
|
|||
|
||||
GST_VIDEO_SINK_WIDTH (glimage_sink) = 1;
|
||||
GST_VIDEO_SINK_HEIGHT (glimage_sink) = 1;
|
||||
if (glimage_sink->display) {
|
||||
GstGLContext *context =
|
||||
gst_gl_display_get_context (glimage_sink->display);
|
||||
GstGLWindow *window = gst_gl_context_get_window (context);
|
||||
if (glimage_sink->context) {
|
||||
GstGLWindow *window = gst_gl_context_get_window (glimage_sink->context);
|
||||
|
||||
gst_gl_window_send_message (window,
|
||||
GST_GL_WINDOW_CB (gst_glimage_sink_cleanup_glthread), glimage_sink);
|
||||
|
@ -527,7 +524,8 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
|
|||
gst_gl_window_set_close_callback (window, NULL, NULL, NULL);
|
||||
|
||||
gst_object_unref (window);
|
||||
gst_object_unref (context);
|
||||
gst_object_unref (glimage_sink->context);
|
||||
glimage_sink->context = NULL;
|
||||
gst_object_unref (glimage_sink->display);
|
||||
glimage_sink->display = NULL;
|
||||
}
|
||||
|
@ -591,9 +589,9 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
|||
height = GST_VIDEO_INFO_HEIGHT (&vinfo);
|
||||
|
||||
if (glimage_sink->tex_id)
|
||||
gst_gl_display_del_texture (glimage_sink->display, &glimage_sink->tex_id);
|
||||
gst_gl_context_del_texture (glimage_sink->context, &glimage_sink->tex_id);
|
||||
//FIXME: this texture seems to be never deleted when going to STATE_NULL
|
||||
gst_gl_display_gen_texture (glimage_sink->display, &glimage_sink->tex_id,
|
||||
gst_gl_context_gen_texture (glimage_sink->context, &glimage_sink->tex_id,
|
||||
GST_VIDEO_INFO_FORMAT (&vinfo), width, height);
|
||||
|
||||
par_n = GST_VIDEO_INFO_PAR_N (&vinfo);
|
||||
|
@ -644,7 +642,7 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
|||
|
||||
glimage_sink->info = vinfo;
|
||||
|
||||
newpool = gst_gl_buffer_pool_new (glimage_sink->display);
|
||||
newpool = gst_gl_buffer_pool_new (glimage_sink->context);
|
||||
structure = gst_buffer_pool_get_config (newpool);
|
||||
gst_buffer_pool_config_set_params (structure, caps, vinfo.size, 2, 0);
|
||||
gst_buffer_pool_set_config (newpool, structure);
|
||||
|
@ -694,7 +692,7 @@ gst_glimage_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
|||
"attempting to wrap for upload");
|
||||
|
||||
if (!glimage_sink->upload) {
|
||||
glimage_sink->upload = gst_gl_upload_new (glimage_sink->display);
|
||||
glimage_sink->upload = gst_gl_upload_new (glimage_sink->context);
|
||||
|
||||
if (!gst_gl_upload_init_format (glimage_sink->upload,
|
||||
GST_VIDEO_FRAME_FORMAT (&frame), GST_VIDEO_FRAME_WIDTH (&frame),
|
||||
|
@ -718,14 +716,12 @@ gst_glimage_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
|||
}
|
||||
|
||||
if (glimage_sink->window_id != glimage_sink->new_window_id) {
|
||||
GstGLContext *context = gst_gl_display_get_context (glimage_sink->display);
|
||||
GstGLWindow *window = gst_gl_context_get_window (context);
|
||||
GstGLWindow *window = gst_gl_context_get_window (glimage_sink->context);
|
||||
|
||||
glimage_sink->window_id = glimage_sink->new_window_id;
|
||||
gst_gl_window_set_window_handle (window, glimage_sink->window_id);
|
||||
|
||||
gst_object_unref (window);
|
||||
gst_object_unref (context);
|
||||
}
|
||||
|
||||
GST_TRACE ("redisplay texture:%u of size:%ux%u, window size:%ux%u", tex_id,
|
||||
|
@ -750,7 +746,7 @@ gst_glimage_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
|||
|
||||
if (g_atomic_int_get (&glimage_sink->to_quit) != 0) {
|
||||
GST_ELEMENT_ERROR (glimage_sink, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
|
@ -761,7 +757,7 @@ redisplay_failed:
|
|||
{
|
||||
gst_video_frame_unmap (&frame);
|
||||
GST_ELEMENT_ERROR (glimage_sink, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -798,15 +794,12 @@ gst_glimage_sink_expose (GstVideoOverlay * overlay)
|
|||
if (glimage_sink->display && glimage_sink->window_id) {
|
||||
|
||||
if (glimage_sink->window_id != glimage_sink->new_window_id) {
|
||||
GstGLContext *context =
|
||||
gst_gl_display_get_context (glimage_sink->display);
|
||||
GstGLWindow *window = gst_gl_context_get_window (context);
|
||||
GstGLWindow *window = gst_gl_context_get_window (glimage_sink->context);
|
||||
|
||||
glimage_sink->window_id = glimage_sink->new_window_id;
|
||||
gst_gl_window_set_window_handle (window, glimage_sink->window_id);
|
||||
|
||||
gst_object_unref (window);
|
||||
gst_object_unref (context);
|
||||
}
|
||||
|
||||
gst_glimage_sink_redisplay (glimage_sink);
|
||||
|
@ -854,7 +847,7 @@ gst_glimage_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
|||
goto invalid_caps;
|
||||
|
||||
GST_DEBUG_OBJECT (glimage_sink, "create new pool");
|
||||
pool = gst_gl_buffer_pool_new (glimage_sink->display);
|
||||
pool = gst_gl_buffer_pool_new (glimage_sink->context);
|
||||
|
||||
/* the normal size of a frame */
|
||||
size = info.size;
|
||||
|
@ -898,7 +891,7 @@ static void
|
|||
gst_glimage_sink_thread_init_redisplay (GstGLImageSink * gl_sink)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gl_sink->redisplay_shader = gst_gl_shader_new (gl_sink->display);
|
||||
gl_sink->redisplay_shader = gst_gl_shader_new (gl_sink->context);
|
||||
|
||||
gst_gl_shader_set_vertex_source (gl_sink->redisplay_shader,
|
||||
redisplay_vertex_shader_str_gles2);
|
||||
|
@ -907,10 +900,10 @@ gst_glimage_sink_thread_init_redisplay (GstGLImageSink * gl_sink)
|
|||
|
||||
gst_gl_shader_compile (gl_sink->redisplay_shader, &error);
|
||||
if (error) {
|
||||
gst_gl_display_set_error (gl_sink->display, "%s", error->message);
|
||||
gst_gl_context_set_error (gl_sink->context, "%s", error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
gst_gl_display_clear_shader (gl_sink->display);
|
||||
gst_gl_context_clear_shader (gl_sink->context);
|
||||
} else {
|
||||
gl_sink->redisplay_attr_position_loc =
|
||||
gst_gl_shader_get_attribute_location (gl_sink->redisplay_shader,
|
||||
|
@ -929,7 +922,7 @@ gst_glimage_sink_on_resize (const GstGLImageSink * gl_sink, gint width,
|
|||
/* Here gl_sink members (ex:gl_sink->info) have a life time of set_caps.
|
||||
* It means that they cannot not change between two set_caps
|
||||
*/
|
||||
const GstGLFuncs *gl = gl_sink->display->gl_vtable;
|
||||
const GstGLFuncs *gl = gl_sink->context->gl_vtable;
|
||||
|
||||
GST_TRACE ("GL Window resized to %ux%u", width, height);
|
||||
|
||||
|
@ -958,7 +951,7 @@ gst_glimage_sink_on_resize (const GstGLImageSink * gl_sink, gint width,
|
|||
gl->Viewport (0, 0, width, height);
|
||||
}
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (gl_sink->display)) {
|
||||
if (USING_OPENGL (gl_sink->context)) {
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
gluOrtho2D (0, width, 0, height);
|
||||
|
@ -982,7 +975,7 @@ gst_glimage_sink_on_draw (const GstGLImageSink * gl_sink)
|
|||
|
||||
g_return_if_fail (GST_IS_GLIMAGE_SINK (gl_sink));
|
||||
|
||||
gl = gl_sink->display->gl_vtable;
|
||||
gl = gl_sink->context->gl_vtable;
|
||||
|
||||
GST_GLIMAGE_SINK_LOCK (gl_sink);
|
||||
|
||||
|
@ -996,10 +989,10 @@ gst_glimage_sink_on_draw (const GstGLImageSink * gl_sink)
|
|||
GST_TRACE ("redrawing texture:%u", gl_sink->redisplay_texture);
|
||||
|
||||
/* make sure that the environnement is clean */
|
||||
gst_gl_display_clear_shader (gl_sink->display);
|
||||
gst_gl_context_clear_shader (gl_sink->context);
|
||||
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (gl_sink->display))
|
||||
if (USING_OPENGL (gl_sink->context))
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
#endif
|
||||
|
||||
|
@ -1015,22 +1008,19 @@ gst_glimage_sink_on_draw (const GstGLImageSink * gl_sink)
|
|||
gl_sink->client_data);
|
||||
|
||||
if (doRedisplay) {
|
||||
GstGLContext *context =
|
||||
gst_gl_display_get_context_unlocked (gl_sink->display);
|
||||
GstGLWindow *window = gst_gl_context_get_window (context);
|
||||
GstGLWindow *window = gst_gl_context_get_window (gl_sink->context);
|
||||
|
||||
gst_gl_window_draw_unlocked (window,
|
||||
GST_VIDEO_INFO_WIDTH (&gl_sink->info),
|
||||
GST_VIDEO_INFO_HEIGHT (&gl_sink->info));
|
||||
|
||||
gst_object_unref (window);
|
||||
gst_object_unref (context);
|
||||
}
|
||||
}
|
||||
/* default opengl scene */
|
||||
else {
|
||||
#if GST_GL_HAVE_OPENGL
|
||||
if (USING_OPENGL (gl_sink->display)) {
|
||||
if (USING_OPENGL (gl_sink->context)) {
|
||||
GLfloat verts[8] = { 1.0f, 1.0f,
|
||||
-1.0f, 1.0f,
|
||||
-1.0f, -1.0f,
|
||||
|
@ -1064,7 +1054,7 @@ gst_glimage_sink_on_draw (const GstGLImageSink * gl_sink)
|
|||
}
|
||||
#endif
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (USING_GLES2 (gl_sink->display)) {
|
||||
if (USING_GLES2 (gl_sink->context)) {
|
||||
const GLfloat vVertices[] = { 1.0f, 1.0f, 0.0f,
|
||||
1.0f, 0.0f,
|
||||
-1.0f, 1.0f, 0.0f,
|
||||
|
@ -1107,7 +1097,7 @@ gst_glimage_sink_on_draw (const GstGLImageSink * gl_sink)
|
|||
static void
|
||||
gst_glimage_sink_on_close (GstGLImageSink * gl_sink)
|
||||
{
|
||||
gst_gl_display_set_error (gl_sink->display, "Output window was closed");
|
||||
gst_gl_context_set_error (gl_sink->context, "Output window was closed");
|
||||
|
||||
g_atomic_int_set (&gl_sink->to_quit, 1);
|
||||
}
|
||||
|
@ -1115,17 +1105,15 @@ gst_glimage_sink_on_close (GstGLImageSink * gl_sink)
|
|||
static gboolean
|
||||
gst_glimage_sink_redisplay (GstGLImageSink * gl_sink)
|
||||
{
|
||||
GstGLContext *context;
|
||||
GstGLWindow *window;
|
||||
gboolean alive;
|
||||
|
||||
context = gst_gl_display_get_context (gl_sink->display);
|
||||
window = gst_gl_context_get_window (context);
|
||||
window = gst_gl_context_get_window (gl_sink->context);
|
||||
|
||||
if (window && gst_gl_window_is_running (window)) {
|
||||
|
||||
#if GST_GL_HAVE_GLES2
|
||||
if (USING_GLES2 (gl_sink->display)) {
|
||||
if (USING_GLES2 (gl_sink->context)) {
|
||||
if (!gl_sink->redisplay_shader) {
|
||||
gst_gl_window_send_message (window,
|
||||
GST_GL_WINDOW_CB (gst_glimage_sink_thread_init_redisplay), gl_sink);
|
||||
|
@ -1141,7 +1129,6 @@ gst_glimage_sink_redisplay (GstGLImageSink * gl_sink)
|
|||
}
|
||||
alive = gst_gl_window_is_running (window);
|
||||
gst_object_unref (window);
|
||||
gst_object_unref (context);
|
||||
|
||||
return alive;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ struct _GstGLImageSink
|
|||
GstVideoInfo info;
|
||||
|
||||
GstGLDisplay *display;
|
||||
GstGLContext *context;
|
||||
GstGLUpload *upload;
|
||||
GLuint tex_id;
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ gst_gl_mosaic_reset (GstGLMixer * mixer)
|
|||
mosaic->input_frames = NULL;
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
gst_gl_display_del_shader (mixer->display, mosaic->shader);
|
||||
gst_gl_context_del_shader (mixer->context, mosaic->shader);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -185,7 +185,7 @@ gst_gl_mosaic_init_shader (GstGLMixer * mixer, GstCaps * outcaps)
|
|||
GstGLMosaic *mosaic = GST_GL_MOSAIC (mixer);
|
||||
|
||||
//blocking call, wait the opengl thread has compiled the shader
|
||||
return gst_gl_display_gen_shader (mixer->display, mosaic_v_src, mosaic_f_src,
|
||||
return gst_gl_context_gen_shader (mixer->context, mosaic_v_src, mosaic_f_src,
|
||||
&mosaic->shader);
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ gst_gl_mosaic_process_textures (GstGLMixer * mix, GArray * in_textures,
|
|||
mosaic->input_frames = in_frames;
|
||||
|
||||
//blocking call, use a FBO
|
||||
gst_gl_display_use_fbo_v2 (mix->display,
|
||||
gst_gl_context_use_fbo_v2 (mix->context,
|
||||
GST_VIDEO_INFO_WIDTH (&mix->out_info),
|
||||
GST_VIDEO_INFO_HEIGHT (&mix->out_info), mix->fbo, mix->depthbuffer,
|
||||
out_tex, gst_gl_mosaic_callback, (gpointer) mosaic);
|
||||
|
@ -213,7 +213,7 @@ gst_gl_mosaic_callback (gpointer stuff)
|
|||
{
|
||||
GstGLMosaic *mosaic = GST_GL_MOSAIC (stuff);
|
||||
GstGLMixer *mixer = GST_GL_MIXER (mosaic);
|
||||
GstGLFuncs *gl = mixer->display->gl_vtable;
|
||||
GstGLFuncs *gl = mixer->context->gl_vtable;
|
||||
|
||||
static GLfloat xrot = 0;
|
||||
static GLfloat yrot = 0;
|
||||
|
@ -235,7 +235,7 @@ gst_gl_mosaic_callback (gpointer stuff)
|
|||
|
||||
guint count = 0;
|
||||
|
||||
gst_gl_display_clear_shader (mixer->display);
|
||||
gst_gl_context_clear_shader (mixer->context);
|
||||
gl->BindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||
gl->Disable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
|
||||
|
@ -360,7 +360,7 @@ gst_gl_mosaic_callback (gpointer stuff)
|
|||
|
||||
gl->Disable (GL_DEPTH_TEST);
|
||||
|
||||
gst_gl_display_clear_shader (mixer->display);
|
||||
gst_gl_context_clear_shader (mixer->context);
|
||||
|
||||
xrot += 0.6f;
|
||||
yrot += 0.4f;
|
||||
|
|
|
@ -108,7 +108,7 @@ static void
|
|||
gst_gl_overlay_reset_gl_resources (GstGLFilter * filter)
|
||||
{
|
||||
GstGLOverlay *overlay = GST_GL_OVERLAY (filter);
|
||||
const GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
const GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->DeleteTextures (1, &overlay->pbuftexture);
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ static void
|
|||
gst_gl_overlay_init_texture (GstGLOverlay * o, GLuint tex, int flag)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (o);
|
||||
const GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
const GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
if (flag == 0 && o->type_file == 2) {
|
||||
gl->Enable (GL_TEXTURE_2D);
|
||||
|
@ -281,7 +281,7 @@ static void
|
|||
gst_gl_overlay_draw (GstGLOverlay * o, int flag)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (o);
|
||||
const GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
const GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
float y = 0.0f;
|
||||
float width = 0.0f;
|
||||
|
@ -325,7 +325,7 @@ gst_gl_overlay_draw (GstGLOverlay * o, int flag)
|
|||
v_vertices[11] = y;
|
||||
v_vertices[16] = y;
|
||||
|
||||
gst_gl_display_clear_shader (filter->display);
|
||||
gst_gl_context_clear_shader (filter->context);
|
||||
|
||||
gl->ClientActiveTexture (GL_TEXTURE0);
|
||||
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
|
@ -368,7 +368,7 @@ static void
|
|||
gst_gl_overlay_load_texture (GstGLOverlay * o, GLuint tex, int flag)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (o);
|
||||
const GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
const GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gfloat video_ratio_w;
|
||||
gfloat video_ratio_h;
|
||||
|
@ -578,7 +578,7 @@ gst_gl_overlay_callback (gint width, gint height, guint texture, gpointer stuff)
|
|||
{
|
||||
GstGLOverlay *overlay = GST_GL_OVERLAY (stuff);
|
||||
GstGLFilter *filter = GST_GL_FILTER (overlay);
|
||||
const GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
const GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
gl->MatrixMode (GL_PROJECTION);
|
||||
gl->LoadIdentity ();
|
||||
|
@ -610,11 +610,11 @@ gst_gl_overlay_callback (gint width, gint height, guint texture, gpointer stuff)
|
|||
}
|
||||
|
||||
static void
|
||||
init_pixbuf_texture (GstGLDisplay * display, gpointer data)
|
||||
init_pixbuf_texture (GstGLContext * context, gpointer data)
|
||||
{
|
||||
GstGLOverlay *overlay = GST_GL_OVERLAY (data);
|
||||
GstGLFilter *filter = GST_GL_FILTER (overlay);
|
||||
const GstGLFuncs *gl = filter->display->gl_vtable;
|
||||
const GstGLFuncs *gl = filter->context->gl_vtable;
|
||||
|
||||
if (overlay->pixbuf) {
|
||||
gl->DeleteTextures (1, &overlay->pbuftexture);
|
||||
|
@ -633,8 +633,6 @@ init_pixbuf_texture (GstGLDisplay * display, gpointer data)
|
|||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
}
|
||||
//else
|
||||
// display->isAlive = FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -647,8 +645,8 @@ gst_gl_overlay_filter_texture (GstGLFilter * filter, guint in_tex,
|
|||
if ((overlay->type_file = gst_gl_overlay_load_png (filter)) == 0)
|
||||
if ((overlay->type_file = gst_gl_overlay_load_jpeg (filter)) == 0)
|
||||
overlay->pixbuf = NULL;
|
||||
/* if loader failed then display is turned off */
|
||||
gst_gl_display_thread_add (filter->display, init_pixbuf_texture, overlay);
|
||||
/* if loader failed then context is turned off */
|
||||
gst_gl_context_thread_add (filter->context, init_pixbuf_texture, overlay);
|
||||
if (overlay->pixbuf) {
|
||||
free (overlay->pixbuf);
|
||||
overlay->pixbuf = NULL;
|
||||
|
@ -731,7 +729,7 @@ gst_gl_overlay_load_png (GstGLFilter * filter)
|
|||
png_byte magic[8];
|
||||
gint n_read;
|
||||
|
||||
if (!filter->display)
|
||||
if (!filter->context)
|
||||
return 1;
|
||||
|
||||
if ((fp = fopen (overlay->location, "rb")) == NULL)
|
||||
|
|
|
@ -315,9 +315,9 @@ gst_gl_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps)
|
|||
out_width = GST_VIDEO_INFO_WIDTH (&gltestsrc->out_info);
|
||||
out_height = GST_VIDEO_INFO_HEIGHT (&gltestsrc->out_info);
|
||||
|
||||
if (!gst_gl_display_gen_fbo (gltestsrc->display, out_width, out_height,
|
||||
if (!gst_gl_context_gen_fbo (gltestsrc->context, out_width, out_height,
|
||||
&gltestsrc->fbo, &gltestsrc->depthbuffer))
|
||||
goto display_error;
|
||||
goto context_error;
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -328,10 +328,10 @@ wrong_caps:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
display_error:
|
||||
context_error:
|
||||
{
|
||||
GST_ELEMENT_ERROR (gltestsrc, RESOURCE, NOT_FOUND,
|
||||
("%s", gst_gl_display_get_error ()), (NULL));
|
||||
("%s", gst_gl_context_get_error ()), (NULL));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -467,14 +467,14 @@ gst_gl_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
|
|||
"attempting to wrap for download");
|
||||
|
||||
if (!src->out_tex_id) {
|
||||
gst_gl_display_gen_texture (src->display, &src->out_tex_id,
|
||||
gst_gl_context_gen_texture (src->context, &src->out_tex_id,
|
||||
GST_VIDEO_FORMAT_RGBA, GST_VIDEO_FRAME_WIDTH (&out_frame),
|
||||
GST_VIDEO_FRAME_HEIGHT (&out_frame));
|
||||
}
|
||||
out_tex = src->out_tex_id;
|
||||
|
||||
if (!src->download) {
|
||||
src->download = gst_gl_download_new (src->display);
|
||||
src->download = gst_gl_download_new (src->context);
|
||||
|
||||
if (!gst_gl_download_init_format (src->download,
|
||||
GST_VIDEO_FRAME_FORMAT (&out_frame),
|
||||
|
@ -492,7 +492,7 @@ gst_gl_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
|
|||
gst_buffer_replace (&src->buffer, buffer);
|
||||
|
||||
//blocking call, generate a FBO
|
||||
if (!gst_gl_display_use_fbo_v2 (src->display, width, height, src->fbo,
|
||||
if (!gst_gl_context_use_fbo_v2 (src->context, width, height, src->fbo,
|
||||
src->depthbuffer, out_tex, gst_gl_test_src_callback,
|
||||
(gpointer) src)) {
|
||||
goto not_negotiated;
|
||||
|
@ -556,21 +556,20 @@ gst_gl_test_src_start (GstBaseSrc * basesrc)
|
|||
}
|
||||
|
||||
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 */
|
||||
src->display =
|
||||
gst_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value)));
|
||||
else {
|
||||
GstGLContext *context;
|
||||
src->context = gst_gl_display_get_context (src->display);
|
||||
} else {
|
||||
GError *error = NULL;
|
||||
|
||||
GST_INFO ("Creating GstGLDisplay");
|
||||
src->display = gst_gl_display_new ();
|
||||
context = gst_gl_context_new (src->display);
|
||||
gst_gl_display_set_context (src->display, context);
|
||||
gst_object_unref (context);
|
||||
src->context = gst_gl_context_new (src->display);
|
||||
gst_gl_display_set_context (src->display, src->context);
|
||||
|
||||
if (!gst_gl_context_create (context, 0, &error)) {
|
||||
if (!gst_gl_context_create (src->context, 0, &error)) {
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
|
||||
("%s", error->message), (NULL));
|
||||
return FALSE;
|
||||
|
@ -589,9 +588,9 @@ gst_gl_test_src_stop (GstBaseSrc * basesrc)
|
|||
{
|
||||
GstGLTestSrc *src = GST_GL_TEST_SRC (basesrc);
|
||||
|
||||
if (src->display) {
|
||||
if (src->context) {
|
||||
if (src->out_tex_id) {
|
||||
gst_gl_display_del_texture (src->display, &src->out_tex_id);
|
||||
gst_gl_context_del_texture (src->context, &src->out_tex_id);
|
||||
}
|
||||
|
||||
if (src->download) {
|
||||
|
@ -599,7 +598,12 @@ gst_gl_test_src_stop (GstBaseSrc * basesrc)
|
|||
src->download = NULL;
|
||||
}
|
||||
//blocking call, delete the FBO
|
||||
gst_gl_display_del_fbo (src->display, src->fbo, src->depthbuffer);
|
||||
gst_gl_context_del_fbo (src->context, src->fbo, src->depthbuffer);
|
||||
gst_object_unref (src->context);
|
||||
src->context = NULL;
|
||||
}
|
||||
|
||||
if (src->display) {
|
||||
gst_object_unref (src->display);
|
||||
src->display = NULL;
|
||||
}
|
||||
|
@ -634,7 +638,7 @@ gst_gl_test_src_decide_allocation (GstBaseSrc * basesrc, GstQuery * query)
|
|||
}
|
||||
|
||||
if (!pool)
|
||||
pool = gst_gl_buffer_pool_new (src->display);
|
||||
pool = gst_gl_buffer_pool_new (src->context);
|
||||
|
||||
config = gst_buffer_pool_get_config (pool);
|
||||
gst_buffer_pool_config_set_params (config, caps, size, min, max);
|
||||
|
|
|
@ -105,6 +105,7 @@ struct _GstGLTestSrc {
|
|||
GstGLDownload *download;
|
||||
|
||||
GstGLDisplay *display;
|
||||
GstGLContext *context;
|
||||
gint64 timestamp_offset; /* base offset */
|
||||
GstClockTime running_time; /* total running time */
|
||||
gint64 n_frames; /* total frames sent */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue