1 /*
2  * GStreamer
3  * Copyright (C) 2008-2010 Filippo Argiolas <filippo.argiolas@gmail.com>
4  * Copyright (C) 2015 Michał Dębski <debski.mi.zd@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include "../gstgleffects.h"
27 
28 void
gst_gl_effects_sobel(GstGLEffects * effects)29 gst_gl_effects_sobel (GstGLEffects * effects)
30 {
31   GstGLFilter *filter = GST_GL_FILTER (effects);
32   GstGLShader *shader;
33 
34   shader = gst_gl_effects_get_fragment_shader (effects, "desat0",
35       desaturate_fragment_source_gles2);
36   gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
37       effects->midtexture[0], shader);
38 
39   shader = gst_gl_effects_get_fragment_shader (effects, "hconv0",
40       sep_sobel_hconv3_fragment_source_gles2);
41   gst_gl_shader_use (shader);
42   gst_gl_shader_set_uniform_1f (shader, "height",
43       GST_VIDEO_INFO_HEIGHT (&filter->out_info));
44   gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[0],
45       effects->midtexture[1], shader);
46 
47   shader = gst_gl_effects_get_fragment_shader (effects, "vconv0",
48       sep_sobel_vconv3_fragment_source_gles2);
49   gst_gl_shader_use (shader);
50   gst_gl_shader_set_uniform_1f (shader, "width",
51       GST_VIDEO_INFO_WIDTH (&filter->out_info));
52   gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[1],
53       effects->midtexture[0], shader);
54 
55   shader = gst_gl_effects_get_fragment_shader (effects, "len0",
56       sep_sobel_length_fragment_source_gles2);
57   gst_gl_shader_use (shader);
58   gst_gl_shader_set_uniform_1i (shader, "invert", effects->invert);
59   gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[0],
60       effects->outtexture, shader);
61 }
62