From 26564461f035ba57ad07215294153c3edf76dcab Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Mon, 11 Aug 2008 15:30:38 +0200 Subject: [PATCH] [145/906] gen/del the middle texture only one time in the gstglfilterblur --- gst/gl/gstglfilterblur.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/gst/gl/gstglfilterblur.c b/gst/gl/gstglfilterblur.c index 9775002..ac2eb62 100644 --- a/gst/gl/gstglfilterblur.c +++ b/gst/gl/gstglfilterblur.c @@ -39,6 +39,8 @@ struct _GstGLFilterBlur GstGLFilter filter; GstGLShader *shader0; GstGLShader *shader1; + + GLuint midtexture; }; struct _GstGLFilterBlurClass @@ -119,22 +121,22 @@ static void gst_gl_filterblur_hcallback (gint width, gint height, guint texture, static void gst_gl_filterblur_vcallback (gint width, gint height, guint texture, gpointer stuff); -static void +static void gst_gl_filterblur_init_resources (GstGLFilter *filter) { // GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter); - + /* dummy gl call to test if we really are in a gl context */ g_print ("\nStart!!!: %s\n\n", glGetString (GL_VERSION)); } -static void +static void gst_gl_filterblur_reset_resources (GstGLFilter *filter) { // GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter); /* dummy gl call to test if we really are in a gl context */ - g_print ("\nStop!!!: %s\n\n", glGetString (GL_VENDOR)); + g_print ("\nStop!!!: %s\n\n", glGetString (GL_VENDOR)); } static void @@ -166,6 +168,7 @@ gst_gl_filterblur_init (GstGLFilterBlur * filterblur, GstGLFilterBlurClass * kla { filterblur->shader0 = NULL; filterblur->shader1 = NULL; + filterblur->midtexture = 0; } static void @@ -178,6 +181,9 @@ gst_gl_filter_filterblur_reset (GstGLFilter* filter) //blocking call, wait the opengl thread has destroyed the shader gst_gl_display_del_shader (filter->display, filterblur->shader1); + + //blocking call, put the texture in the pool + gst_gl_display_del_texture (filter->display, filterblur->midtexture); } static void @@ -211,6 +217,9 @@ gst_gl_filterblur_init_shader (GstGLFilter* filter) { GstGLFilterBlur* blur_filter = GST_GL_FILTERBLUR (filter); + //blocking call, generate a texture using the pool + gst_gl_display_gen_texture (filter->display, &blur_filter->midtexture) ; + //blocking call, wait the opengl thread has compiled the shader gst_gl_display_gen_shader (filter->display, hconv9_fragment_source, &blur_filter->shader0); @@ -252,7 +261,7 @@ change_view (GstGLDisplay *display, gpointer data) 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; - + glMatrixMode (GL_MODELVIEW); glLoadMatrixd (mirrormatrix); } @@ -261,23 +270,16 @@ static gboolean gst_gl_filterblur_filter (GstGLFilter* filter, GstGLBuffer* inbuf, GstGLBuffer* outbuf) { - gpointer filterblur = GST_GL_FILTERBLUR(filter); - GLuint midtexture = 0; - - //blocking call, generate a texture using the pool - gst_gl_display_gen_texture (filter->display, &midtexture) ; + GstGLFilterBlur* filterblur = GST_GL_FILTERBLUR(filter); - gst_gl_filter_render_to_target (filter, inbuf->texture, midtexture, + gst_gl_filter_render_to_target (filter, inbuf->texture, filterblur->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_filter_render_to_target (filter, filterblur->midtexture, outbuf->texture, gst_gl_filterblur_vcallback, filterblur); - //blocking call, put the texture in the pool - gst_gl_display_del_texture (filter->display, midtexture); - return TRUE; } -- 2.7.4