static void gst_gl_display_thread_set_visible_context (GstGLDisplay* display);
static void gst_gl_display_thread_resize_context (GstGLDisplay* display);
static void gst_gl_display_thread_redisplay (GstGLDisplay* display);
+static void gst_gl_display_thread_run_generic (GstGLDisplay *display);
static void gst_gl_display_thread_gen_texture (GstGLDisplay* display);
static void gst_gl_display_thread_del_texture (GstGLDisplay* display);
static void gst_gl_display_thread_init_upload (GstGLDisplay* display);
display->cond_create_context = g_cond_new ();
display->cond_destroy_context = g_cond_new ();
display->cond_change_context = g_cond_new ();
+ display->cond_generic = g_cond_new ();
display->cond_gen_texture = g_cond_new ();
display->cond_del_texture = g_cond_new ();
display->cond_init_upload = g_cond_new ();
g_cond_free (display->cond_gen_texture);
display->cond_gen_texture = NULL;
}
+ if (display->cond_gen_texture) {
+ g_cond_free (display->cond_gen_texture);
+ display->cond_gen_texture = NULL;
+ }
if (display->cond_change_context) {
g_cond_free (display->cond_change_context);
display->cond_change_context = NULL;
case GST_GL_DISPLAY_ACTION_REDISPLAY_CONTEXT:
gst_gl_display_thread_redisplay (msg->display);
break;
+ case GST_GL_DISPLAY_ACTION_GENERIC:
+ gst_gl_display_thread_run_generic (msg->display);
+ break;
case GST_GL_DISPLAY_ACTION_GEN_TEXTURE:
gst_gl_display_thread_gen_texture (msg->display);
break;
case GST_GL_DISPLAY_ACTION_VISIBLE_CONTEXT:
case GST_GL_DISPLAY_ACTION_RESIZE_CONTEXT:
case GST_GL_DISPLAY_ACTION_REDISPLAY_CONTEXT:
+ case GST_GL_DISPLAY_ACTION_GENERIC:
case GST_GL_DISPLAY_ACTION_GEN_TEXTURE:
case GST_GL_DISPLAY_ACTION_DEL_TEXTURE:
case GST_GL_DISPLAY_ACTION_INIT_UPLOAD:
glutPostRedisplay ();
}
+static void
+gst_gl_display_thread_run_generic (GstGLDisplay *display)
+{
+ glutSetWindow (display->glutWinId);
+ display->generic_callback (display, display->data);
+ g_cond_signal (display->cond_generic);
+}
/* Called in the gl thread */
static void
return isAlive;
}
+void
+gst_gl_display_thread_add (GstGLDisplay *display,
+ GstGLDisplayThreadFunc func, gpointer data)
+{
+ gst_gl_display_lock (display);
+ display->data = data;
+ display->generic_callback = func;
+ gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_GENERIC, display);
+ g_cond_wait (display->cond_generic, display->mutex);
+ gst_gl_display_unlock (display);
+}
/* Called by gst_gl_buffer_new */
void
GST_GL_DISPLAY_ACTION_VISIBLE_CONTEXT,
GST_GL_DISPLAY_ACTION_RESIZE_CONTEXT,
GST_GL_DISPLAY_ACTION_REDISPLAY_CONTEXT,
+ GST_GL_DISPLAY_ACTION_GENERIC,
GST_GL_DISPLAY_ACTION_GEN_TEXTURE,
GST_GL_DISPLAY_ACTION_DEL_TEXTURE,
GST_GL_DISPLAY_ACTION_INIT_UPLOAD,
typedef void (* CRCB) ( GLuint, GLuint );
typedef gboolean (* CDCB) ( GLuint, GLuint, GLuint);
+typedef void (* GstGLDisplayThreadFunc) (GstGLDisplay *display, gpointer data);
+
//opengl scene callback
typedef void (* GLCB) ( gint, gint, guint, gpointer stuff);
GCond* cond_create_context;
GCond* cond_destroy_context;
GCond* cond_change_context;
+ GCond* cond_generic;
GCond* cond_gen_texture;
GCond* cond_del_texture;
GCond* cond_init_upload;
GCond* cond_gen_shader;
GCond* cond_del_shader;
+ //generic gl code
+ GstGLDisplayThreadFunc generic_callback;
+ gpointer data;
+
//action redisplay
GLuint redisplay_texture;
GLuint redisplay_texture_width;
void gst_gl_display_resize_context (GstGLDisplay* display, gint width, gint height);
gboolean gst_gl_display_redisplay (GstGLDisplay* display, GLuint texture, gint width, gint height);
+void gst_gl_display_thread_add (GstGLDisplay *display,
+ GstGLDisplayThreadFunc func, gpointer data);
+
void gst_gl_display_gen_texture (GstGLDisplay* display, GLuint* pTexture);
void gst_gl_display_del_texture (GstGLDisplay* display, GLuint texture);
glEnd ();
}
+static void
+change_view (GstGLDisplay *display, gpointer data)
+{
+// GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (data);
+
+ const double 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
+ };
+
+ glMatrixMode (GL_MODELVIEW);
+ glLoadMatrixd (mirrormatrix);
+}
+
static gboolean
gst_gl_filterblur_filter (GstGLFilter* filter, GstGLBuffer* inbuf,
GstGLBuffer* outbuf)
gst_gl_filter_render_to_target (filter, inbuf->texture, midtexture,
gst_gl_filterblur_hcallback, filterblur);
+
+ gst_gl_display_thread_add (filter->display, change_view, filterblur);
+
gst_gl_filter_render_to_target (filter, midtexture, outbuf->texture,
gst_gl_filterblur_vcallback, filterblur);