}
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);
* 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);
{
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);
{
GstBufferPool bufferpool;
- GstGLDisplay *display;
+ GstGLContext *context;
GstGLBufferPoolPrivate *priv;
};
GstBufferPoolClass parent_class;
};
-GstBufferPool *gst_gl_buffer_pool_new (GstGLDisplay * display);
+GstBufferPool *gst_gl_buffer_pool_new (GstGLContext * context);
G_END_DECLS
{
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);
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);
_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",
}
#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)
_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",
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)
}
display = context->priv->display;
- gl = display->gl_vtable;
+ gl = context->gl_vtable;
compiled_api = _compiled_api ();
user_choice = g_getenv ("GST_GL_API");
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);
+}
#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,
/*< public >*/
GstGLWindow *window;
+ GstGLFuncs *gl_vtable;
+
/*< private >*/
gpointer _reserved[GST_PADDING];
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);
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__ */
{
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 ();
{
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;
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)
{
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)
{
#define GST_GL_DISPLAY_CAST(obj) ((GstGLDisplay*)(obj))
/**
- * GstGLDisplayThreadFunc:
- * @display: a #GstGLDisplay
- * @data: user data
- *
- * Represents a function to run in the GL thread
- */
-typedef void (*GstGLDisplayThreadFunc) (GstGLDisplay * display, gpointer data);
-
-/**
* GstGLDisplay:
*
* the contents of a #GstGLDisplay are private and should only be accessed
GstGLContext *context;
GstGLAPI gl_api;
- GstGLFuncs *gl_vtable;
-
GstGLDisplayPrivate *priv;
};
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);
* A #GstGLDownload can be created with gst_gl_download_new()
*/
-#define USING_OPENGL(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL)
-#define USING_OPENGL3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL3)
-#define USING_GLES(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES)
-#define USING_GLES2(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES2)
-#define USING_GLES3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES3)
-
-static void _do_download (GstGLDisplay * display, GstGLDownload * download);
-static void _init_download (GstGLDisplay * display, GstGLDownload * download);
-static gboolean _init_download_shader (GstGLDisplay * display,
+#define USING_OPENGL(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL)
+#define USING_OPENGL3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL3)
+#define USING_GLES(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES)
+#define USING_GLES2(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2)
+#define USING_GLES3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES3)
+
+static void _do_download (GstGLContext * context, GstGLDownload * download);
+static void _init_download (GstGLContext * context, GstGLDownload * download);
+static gboolean _init_download_shader (GstGLContext * context,
GstGLDownload * download);
static gboolean _gst_gl_download_perform_with_data_unlocked (GstGLDownload *
download, GLuint texture_id, gpointer data[GST_VIDEO_MAX_PLANES]);
#if GST_GL_HAVE_OPENGL
-static void _do_download_draw_rgb_opengl (GstGLDisplay * display,
+static void _do_download_draw_rgb_opengl (GstGLContext * context,
GstGLDownload * download);
-static void _do_download_draw_yuv_opengl (GstGLDisplay * display,
+static void _do_download_draw_yuv_opengl (GstGLContext * context,
GstGLDownload * download);
#endif
#if GST_GL_HAVE_GLES2
-static void _do_download_draw_rgb_gles2 (GstGLDisplay * display,
+static void _do_download_draw_rgb_gles2 (GstGLContext * context,
GstGLDownload * download);
-static void _do_download_draw_yuv_gles2 (GstGLDisplay * display,
+static void _do_download_draw_yuv_gles2 (GstGLContext * context,
GstGLDownload * download);
#endif
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;
};
download->priv = GST_GL_DOWNLOAD_GET_PRIVATE (download);
- download->display = NULL;
+ download->context = NULL;
g_mutex_init (&download->lock);
/**
* 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;
}
#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;
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;
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);
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;
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);
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:
/* 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;
}
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,
}
#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);
}
/* 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);
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:
}
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;
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);
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;
}
}
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:
*/
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;;
}
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");
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");
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");
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,
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;
/* 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;
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:
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;
#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);
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;
#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;
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);
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]);
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;
out_width, out_height
};
- gl = display->gl_vtable;
+ gl = context->gl_vtable;
v_format = GST_VIDEO_INFO_FORMAT (&download->info);
default:
break;
- gst_gl_display_set_error (display,
+ gst_gl_context_set_error (context,
"Download video format inconsistensy %d", v_format);
}
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);
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);
}
#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;
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);
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);
default:
break;
- gst_gl_display_set_error (display,
+ gst_gl_context_set_error (context,
"Download video format inconsistensy %d", v_format);
}
* 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]);
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
GMutex lock;
- GstGLDisplay *display;
+ GstGLContext *context;
/* output data */
GstVideoInfo info;
*/
#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);
}
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)
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 = "";
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;
}
g_free (full_function_name);
- gst_object_unref (context);
return TRUE;
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);
}
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,
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);
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)
{
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;
}
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;
}
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);
}
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);
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)
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;
}
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;
}
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);
"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),
"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),
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),
}
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),
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,
_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 ();
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;
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,
GstBufferPool *pool;
GstGLDisplay *display;
+ GstGLContext *context;
GstVideoInfo in_info;
GstVideoInfo out_info;
{
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;
}
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;
}
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);
}
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;
}
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,
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 ();
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);
}
}
#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);
}
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);
}
#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]);
}
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);
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);
GObject object;
/* <private> */
- GstGLDisplay *display;
+ GstGLContext *context;
GstGLFramebufferPrivate *priv;
};
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);
* 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
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;
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;
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
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;
}
void
-_gl_mem_copy_thread (GstGLDisplay * display, gpointer data)
+_gl_mem_copy_thread (GstGLContext * context, gpointer data)
{
GstGLMemoryCopyParams *copy_params;
GstGLMemory *src;
gsize width, height;
GLuint gl_format;
GstVideoFormat v_format;
- GstGLFuncs *gl = display->gl_vtable;
+ GstGLFuncs *gl;
copy_params = (GstGLMemoryCopyParams *) data;
src = copy_params->src;
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);
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);
}
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);
}
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 */
gl->DeleteFramebuffers (1, &fboId);
copy_params->tex_id = 0;
+
+ return;
+ }
+
+error:
+ {
+ return;
}
}
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);
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)
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);
/**
* 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);
/**
* 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
* @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;
{
GstMemory mem;
- GstGLDisplay *display;
+ GstGLContext *context;
GLuint tex_id;
GstVideoFormat v_format;
GLenum gl_format;
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);
}
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;
}
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);
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);
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;
}
}
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),
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)) {
}
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);
}
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;
}
gst_object_unref (mix->display);
mix->display = NULL;
}
+
+ if (mix->context) {
+ gst_object_unref (mix->context);
+ mix->context = NULL;
+ }
break;
}
default:
guint64 qos_processed, qos_dropped;
GstGLDisplay *display;
+ GstGLContext *context;
GLuint fbo;
GLuint depthbuffer;
};
#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
{
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;
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);
}
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) {
}
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;
}
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 ();
}
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);
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;
}
}
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
}
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);
}
/*< private >*/
GObject parent;
- GstGLDisplay *display;
+ GstGLContext *context;
GstGLShaderPrivate *priv;
};
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);
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);
* A #GstGLUpload can be created with gst_gl_upload_new()
*/
-#define USING_OPENGL(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL)
-#define USING_OPENGL3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_OPENGL3)
-#define USING_GLES(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES)
-#define USING_GLES2(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES2)
-#define USING_GLES3(display) (gst_gl_display_get_gl_api (display) & GST_GL_API_GLES3)
-
-static void _do_upload (GstGLDisplay * display, GstGLUpload * upload);
-static gboolean _do_upload_fill (GstGLDisplay * display, GstGLUpload * upload);
-static gboolean _do_upload_make (GstGLDisplay * display, GstGLUpload * upload);
-static void _init_upload (GstGLDisplay * display, GstGLUpload * upload);
-static gboolean _init_upload_fbo (GstGLDisplay * display, GstGLUpload * upload);
+#define USING_OPENGL(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL)
+#define USING_OPENGL3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL3)
+#define USING_GLES(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES)
+#define USING_GLES2(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2)
+#define USING_GLES3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES3)
+
+static void _do_upload (GstGLContext * context, GstGLUpload * upload);
+static gboolean _do_upload_fill (GstGLContext * context, GstGLUpload * upload);
+static gboolean _do_upload_make (GstGLContext * context, GstGLUpload * upload);
+static void _init_upload (GstGLContext * context, GstGLUpload * upload);
+static gboolean _init_upload_fbo (GstGLContext * context, GstGLUpload * upload);
static gboolean _gst_gl_upload_perform_with_data_unlocked (GstGLUpload * upload,
GLuint texture_id, gpointer data[GST_VIDEO_MAX_PLANES]);
#if GST_GL_HAVE_OPENGL
-static gboolean _do_upload_draw_opengl (GstGLDisplay * display,
+static gboolean _do_upload_draw_opengl (GstGLContext * context,
GstGLUpload * upload);
#endif
#if GST_GL_HAVE_GLES2
-static gboolean _do_upload_draw_gles2 (GstGLDisplay * display,
+static gboolean _do_upload_draw_gles2 (GstGLContext * context,
GstGLUpload * upload);
#endif
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);
{
upload->priv = GST_GL_UPLOAD_GET_PRIVATE (upload);
- upload->display = NULL;
+ upload->context = NULL;
g_mutex_init (&upload->lock);
/**
* 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;
}
#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;
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;
}
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);
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);
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;
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);
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;
}
/* 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);
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:
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');
}
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);
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;
/* 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;
}
/* 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);
}
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;
}
/* 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;
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;
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;
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;
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;
}
-/* 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;
}
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;
#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;
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);
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);
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;
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);
gl->PopMatrix ();
gl->PopAttrib ();
- gst_gl_display_check_framebuffer_status (display);
+ gst_gl_context_check_framebuffer_status (context);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
#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;
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);
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);
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;
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);
GMutex lock;
- GstGLDisplay *display;
+ GstGLContext *context;
/* input data */
GstVideoInfo info;
*/
#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,
#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;
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);
}
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:
}
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)) {
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
} 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);
} 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,
* 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,
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);
} 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,
}
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);
/* 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;
}
/* 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;
}
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);
}
#include <gst/gl/gstgl_fwd.h>
/**
- * GstGLDisplayProjection:
+ * GstGLContextProjection:
*
* %GST_GL_DISPLAY_PROJECTION_ORTHO2D: Orthogonal projection
* %GST_GL_DISPLAY_CONVERSION_MATRIX: Perspective projection
*/
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__ */
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
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
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);
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 */
/* 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;
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 */
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);