From 77fc21467061a940b2eaf7679cec395f23ac7d7d Mon Sep 17 00:00:00 2001 From: Filippo Argiolas Date: Wed, 13 Aug 2008 22:36:13 +0200 Subject: [PATCH] [159/906] still some source tree reorganize, fixed some issue with headers and ifdefs, moved identity into effects dir --- gst/gl/Makefile.am | 9 +++-- gst/gl/effects/gstgleffectidentity.c | 40 +++++++++++++++++++ gst/gl/effects/gstgleffectmirror.c | 7 +--- gst/gl/effects/gstgleffects.h | 10 +++++ gst/gl/effects/gstgleffectssources.h | 18 ++------- gst/gl/gstgleffects.c | 57 +++++++++------------------- 6 files changed, 78 insertions(+), 63 deletions(-) create mode 100644 gst/gl/effects/gstgleffectidentity.c diff --git a/gst/gl/Makefile.am b/gst/gl/Makefile.am index 5b49503e0b..0fe8339469 100644 --- a/gst/gl/Makefile.am +++ b/gst/gl/Makefile.am @@ -25,9 +25,11 @@ libgstopengl_la_SOURCES = \ gltestsrc.h \ gstgltestsrc.c \ gstgltestsrc.h \ - gstgleffects.c \ + gstgleffects.c \ effects/gstgleffects.h \ - effects/gstgleffectsources.h \ + effects/gstgleffectssources.c \ + effects/gstgleffectssources.h \ + effects/gstgleffectidentity.c \ effects/gstgleffectmirror.c @@ -37,7 +39,8 @@ libgstopengl_la_CFLAGS = $(GST_CFLAGS) $(X_CFLAGS) $(GST_BASE_CFLAGS) \ $(GST_PLUGINS_BASE_CFLAGS) $(GL_CFLAGS) \ -I$(top_srcdir)/gst-libs \ -I$(top_srcdir)/gst-libs/gst/freeglut \ - -I$(top_srcdir)/gst-libs/gst/gl + -I$(top_srcdir)/gst-libs/gst/gl \ + -I$(top_srcdir)/gst/gl/effects libgstopengl_la_LIBADD = \ $(top_builddir)/gst-libs/gst/freeglut/libgstfreeglut-$(GST_MAJORMINOR).la \ $(top_builddir)/gst-libs/gst/gl/libgstgl-$(GST_MAJORMINOR).la \ diff --git a/gst/gl/effects/gstgleffectidentity.c b/gst/gl/effects/gstgleffectidentity.c new file mode 100644 index 0000000000..39401db0bc --- /dev/null +++ b/gst/gl/effects/gstgleffectidentity.c @@ -0,0 +1,40 @@ +/* + * GStreamer + * Copyright (C) 2008 Filippo Argiolas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +static void +gst_gl_effects_identity_callback (gint width, gint height, guint texture, gpointer data) +{ + GstGLEffects* effects = GST_GL_EFFECTS (data); + + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + + gst_gl_effects_draw_texture (effects, texture); +} + +void +gst_gl_effects_identity (GstGLEffects *effects) { + GstGLFilter *filter = GST_GL_FILTER (effects); + + gst_gl_filter_render_to_target (filter, effects->intexture, effects->outtexture, + gst_gl_effects_identity_callback, effects); +} diff --git a/gst/gl/effects/gstgleffectmirror.c b/gst/gl/effects/gstgleffectmirror.c index 5f6e110a49..11f3ad8a7d 100644 --- a/gst/gl/effects/gstgleffectmirror.c +++ b/gst/gl/effects/gstgleffectmirror.c @@ -18,12 +18,7 @@ * Boston, MA 02111-1307, USA. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstgleffects.h" -#include "gstgleffectssources.h" +#include static void gst_gl_effects_mirror_callback (gint width, gint height, guint texture, gpointer data) diff --git a/gst/gl/effects/gstgleffects.h b/gst/gl/effects/gstgleffects.h index 77ed462081..174341ba0e 100644 --- a/gst/gl/effects/gstgleffects.h +++ b/gst/gl/effects/gstgleffects.h @@ -26,9 +26,11 @@ #endif #include +#include G_BEGIN_DECLS + #define GST_TYPE_GL_EFFECTS (gst_gl_effects_get_type()) #define GST_GL_EFFECTS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_GL_EFFECTS,GstGLEffects)) #define GST_IS_GL_EFFECTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_GL_EFFECTS)) @@ -62,10 +64,18 @@ struct _GstGLEffectsClass GstGLFilterClass filter_class; }; +enum +{ + PROP_0, + PROP_EFFECT +}; + + GType gst_gl_effects_get_type (void); void gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex); +void gst_gl_effects_identity (GstGLEffects *effects); void gst_gl_effects_mirror (GstGLEffects *effects); G_END_DECLS diff --git a/gst/gl/effects/gstgleffectssources.h b/gst/gl/effects/gstgleffectssources.h index 78097e7e45..f58fe89b5e 100644 --- a/gst/gl/effects/gstgleffectssources.h +++ b/gst/gl/effects/gstgleffectssources.h @@ -18,23 +18,11 @@ * Boston, MA 02111-1307, USA. */ +#include + #ifndef __GST_GL_EFFECTS_SOURCES_H__ #define __GST_GL_EFFECTS_SOURCES_H__ -/* Mirror effect */ -static const gchar *mirror_fragment_source = - "#extension GL_ARB_texture_rectangle : enable\n" - "uniform sampler2DRect tex;" - "uniform float width, height;" - "void main () {" - " vec2 tex_size = vec2 (width, height);" - " vec2 texturecoord = gl_TexCoord[0].xy;" - " vec2 normcoord;" - " normcoord = texturecoord / tex_size - 1.0;" - " normcoord.x *= sign (normcoord.x);" - " texturecoord = (normcoord + 1.0) * tex_size;" - " vec4 color = texture2DRect (tex, texturecoord); " - " gl_FragColor = color * gl_Color;" - "}"; +const gchar *mirror_fragment_source; #endif /* __GST_GL_EFFECTS_SOURCES_H__ */ diff --git a/gst/gl/gstgleffects.c b/gst/gl/gstgleffects.c index f85f063200..43b01788a6 100644 --- a/gst/gl/gstgleffects.c +++ b/gst/gl/gstgleffects.c @@ -18,7 +18,7 @@ * Boston, MA 02111-1307, USA. */ -#include "effects/gstgleffects.h" +#include #define GST_TYPE_GL_EFFECTS (gst_gl_effects_get_type()) #define GST_GL_EFFECTS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_GL_EFFECTS,GstGLEffects)) @@ -27,12 +27,6 @@ #define GST_IS_GL_EFFECTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) , GST_TYPE_GL_EFFECTS)) #define GST_GL_EFFECTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) , GST_TYPE_GL_EFFECTS,GstGLEffectsClass)) -typedef enum { - GST_GL_EFFECT_IDENTITY, - GST_GL_EFFECT_MIRROR, - GST_GL_N_EFFECTS -} GstGLEffectsEffect; - #define GST_CAT_DEFAULT gst_gl_effects_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); @@ -53,6 +47,19 @@ static void gst_gl_effects_reset_resources (GstGLFilter* filter); static gboolean gst_gl_effects_filter (GstGLFilter * filter, GstGLBuffer * inbuf, GstGLBuffer * outbuf); +static const GstElementDetails element_details = GST_ELEMENT_DETAILS ( + "Gstreamer OpenGL Effects", + "Filter/Effect", + "GL Shading Language effects", + "Filippo Argiolas "); + + +typedef enum { + GST_GL_EFFECT_IDENTITY, + GST_GL_EFFECT_MIRROR, + GST_GL_N_EFFECTS +} GstGLEffectsEffect; + #define GST_TYPE_GL_EFFECTS_EFFECT (gst_gl_effects_effect_get_type ()) static GType gst_gl_effects_effect_get_type (void) @@ -71,18 +78,7 @@ gst_gl_effects_effect_get_type (void) return gl_effects_effect_type; } -static const GstElementDetails element_details = GST_ELEMENT_DETAILS ( - "Gstreamer OpenGL Effects", - "Filter/Effect", - "GL Shading Language effects", - "Filippo Argiolas "); - -enum -{ - PROP_0, - PROP_EFFECT -}; - +/* init resources that need a gl context */ static void gst_gl_effects_init_gl_resources (GstGLFilter *filter) { @@ -101,6 +97,7 @@ gst_gl_effects_init_gl_resources (GstGLFilter *filter) } } +/* free resources that need a gl context */ static void gst_gl_effects_reset_gl_resources (GstGLFilter *filter) { @@ -170,17 +167,7 @@ gst_gl_effects_draw_texture (GstGLEffects * effects, GLuint tex) glEnd (); } -static void -gst_gl_effects_identity_callback (gint width, gint height, guint texture, gpointer data) -{ - GstGLEffects* effects = GST_GL_EFFECTS (data); - - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - - gst_gl_effects_draw_texture (effects, texture); -} - +#if 0 static void change_view (GstGLDisplay *display, gpointer data) { @@ -196,15 +183,7 @@ change_view (GstGLDisplay *display, gpointer data) glMatrixMode (GL_MODELVIEW); glLoadMatrixd (mirrormatrix); } - -static void -gst_gl_effects_identity (GstGLEffects *effects) { - GstGLFilter *filter = GST_GL_FILTER (effects); - - gst_gl_display_thread_add (filter->display, change_view, effects); - gst_gl_filter_render_to_target (filter, effects->intexture, effects->outtexture, - gst_gl_effects_identity_callback, effects); -} +#endif static void gst_gl_effects_init (GstGLEffects * effects, GstGLEffectsClass * klass)