gst_gl_context_del_shader() can be replaced by a g_object_unref().
gst_gl_context_gen_shader() should be replaced by using GstGLSLStage.
gstgldeinterlace.c \
gstglstereomix.c \
gltestsrc.c \
- gstgltestsrc.c
+ gstgltestsrc.c \
+ gstglutils.c
noinst_HEADERS = \
gstglbasemixer.h \
gstgldeinterlace.h \
gstglviewconvert.h \
gltestsrc.h \
- gstgltestsrc.h
+ gstgltestsrc.h \
+ gstglutils.h
# full opengl required
if USE_OPENGL
gpointer data)
{
GstGLShader *shader = (GstGLShader *) value;
- GstGLFilter *filter = (GstGLFilter *) data;
- //blocking call, wait the opengl thread has destroyed the shader
- gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, shader);
+ gst_object_unref (shader);
value = NULL;
}
gst_gl_effects_ghash_func_clean (gpointer key, gpointer value, gpointer data)
{
GstGLShader *shader = (GstGLShader *) value;
- GstGLFilter *filter = (GstGLFilter *) data;
- //blocking call, wait the opengl thread has destroyed the shader
- gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context, shader);
+ gst_object_unref (shader);
value = NULL;
}
#include <gst/gl/gstglapi.h>
#include "gstglfiltercube.h"
+#include "gstglutils.h"
#define GST_CAT_DEFAULT gst_gl_filter_cube_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
#include <math.h>
#include "gstglfilterglass.h"
+#include "gstglutils.h"
#define GST_CAT_DEFAULT gst_gl_filter_glass_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
//blocking call, wait the opengl thread has destroyed the shader
if (glass_filter->shader)
- gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context,
- glass_filter->shader);
+ gst_object_unref (glass_filter->shader);
glass_filter->shader = NULL;
if (glass_filter->passthrough_shader)
- gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context,
- glass_filter->passthrough_shader);
+ gst_object_unref (glass_filter->passthrough_shader);
glass_filter->passthrough_shader = NULL;
return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
#endif
#include "gstglmosaic.h"
+#include "gstglutils.h"
#define GST_CAT_DEFAULT gst_gl_mosaic_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
//blocking call, wait the opengl thread has destroyed the shader
if (mosaic->shader)
- gst_gl_context_del_shader (GST_GL_BASE_MIXER (mixer)->context,
- mosaic->shader);
+ gst_object_unref (mosaic->shader);
mosaic->shader = NULL;
}
#include "gstgloverlay.h"
#include "effects/gstgleffectssources.h"
+#include "gstglutils.h"
#include <stdio.h>
#include <stdlib.h>
#include <gst/gl/gstglapi.h>
#include <graphene-gobject.h>
+#include "gstglutils.h"
#define GST_CAT_DEFAULT gst_gl_transformation_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
#include "gstglvideomixer.h"
#include "gstglmixerbin.h"
+#include "gstglutils.h"
#define GST_CAT_DEFAULT gst_gl_video_mixer_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
GST_DEBUG_OBJECT (mixer, "context:%p", context);
if (video_mixer->shader)
- gst_gl_context_del_shader (context, video_mixer->shader);
+ gst_object_unref (video_mixer->shader);
video_mixer->shader = NULL;
if (video_mixer->checker)
- gst_gl_context_del_shader (context, video_mixer->checker);
+ gst_object_unref (video_mixer->checker);
video_mixer->checker = NULL;
if (GST_GL_BASE_MIXER (mixer)->context)
GstGLVideoMixer *video_mixer = GST_GL_VIDEO_MIXER (mixer);
if (video_mixer->shader)
- gst_gl_context_del_shader (GST_GL_BASE_MIXER (mixer)->context,
- video_mixer->shader);
+ gst_object_unref (video_mixer->shader);
return gst_gl_context_gen_shader (GST_GL_BASE_MIXER (mixer)->context,
gst_gl_shader_string_vertex_mat4_vertex_transform,
'gstglstereomix.c',
'gltestsrc.c',
'gstgltestsrc.c',
+ 'gstglutils.c'
]
if build_gstgl and gstgl_dep.found()
#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
-struct _compile_shader
-{
- GstGLShader **shader;
- const gchar *vertex_src;
- const gchar *fragment_src;
-};
-
-static void
-_compile_shader (GstGLContext * context, struct _compile_shader *data)
-{
- GstGLShader *shader;
- GstGLSLStage *vert, *frag;
- GError *error = NULL;
-
- shader = gst_gl_shader_new (context);
-
- if (data->vertex_src) {
- vert = gst_glsl_stage_new_with_string (context, GL_VERTEX_SHADER,
- GST_GLSL_VERSION_NONE,
- GST_GLSL_PROFILE_ES | GST_GLSL_PROFILE_COMPATIBILITY, data->vertex_src);
- if (!gst_glsl_stage_compile (vert, &error)) {
- GST_ERROR_OBJECT (vert, "%s", error->message);
- gst_object_unref (vert);
- gst_object_unref (shader);
- return;
- }
- if (!gst_gl_shader_attach (shader, vert)) {
- gst_object_unref (shader);
- return;
- }
- }
-
- if (data->fragment_src) {
- frag = gst_glsl_stage_new_with_string (context, GL_FRAGMENT_SHADER,
- GST_GLSL_VERSION_NONE,
- GST_GLSL_PROFILE_ES | GST_GLSL_PROFILE_COMPATIBILITY,
- data->fragment_src);
- if (!gst_glsl_stage_compile (frag, &error)) {
- GST_ERROR_OBJECT (frag, "%s", error->message);
- gst_object_unref (frag);
- gst_object_unref (shader);
- return;
- }
- if (!gst_gl_shader_attach (shader, frag)) {
- gst_object_unref (shader);
- return;
- }
- }
-
- if (!gst_gl_shader_link (shader, &error)) {
- GST_ERROR_OBJECT (shader, "%s", error->message);
- g_error_free (error);
- error = NULL;
- gst_gl_context_clear_shader (context);
- gst_object_unref (shader);
- return;
- }
-
- *data->shader = shader;
-}
-
-/* Called by glfilter */
-gboolean
-gst_gl_context_gen_shader (GstGLContext * context, const gchar * vert_src,
- const gchar * frag_src, GstGLShader ** shader)
-{
- struct _compile_shader data;
-
- g_return_val_if_fail (frag_src != NULL || vert_src != NULL, FALSE);
- g_return_val_if_fail (shader != NULL, FALSE);
-
- data.shader = shader;
- data.vertex_src = vert_src;
- data.fragment_src = frag_src;
-
- gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _compile_shader,
- &data);
-
- return *shader != NULL;
-}
-
-/* Called by glfilter */
-void
-gst_gl_context_del_shader (GstGLContext * context, GstGLShader * shader)
-{
- gst_object_unref (shader);
-}
static gboolean
gst_gl_display_found (GstElement * element, GstGLDisplay * display)
G_BEGIN_DECLS
-GST_EXPORT
-gboolean gst_gl_context_gen_shader (GstGLContext * context,
- const gchar * shader_vertex_source,
- const gchar * shader_fragment_source, GstGLShader ** shader);
-GST_EXPORT
-void gst_gl_context_del_shader (GstGLContext * context, GstGLShader * shader);
-
GST_EXPORT
gboolean gst_gl_ensure_element_data (gpointer element,
GstGLDisplay **display_ptr, GstGLContext ** other_context_ptr);
{
g_return_if_fail (GST_IS_GL_VIEW_CONVERT (viewconvert));
if (viewconvert->shader)
- gst_gl_context_del_shader (viewconvert->context, viewconvert->shader);
+ gst_object_unref (viewconvert->shader);
viewconvert->shader = NULL;
if (viewconvert->fbo)