Commit b3d8e098 authored by Matthew Waters's avatar Matthew Waters 🐨 Committed by Tim-Philipp Müller

glfilter: rewrite subclasses for filter_texture() occuring on GL thread

There's no need for the jump to an extra thread in most cases, especially
when relying solely on a shader to render.  We can use the provided
render_to_target() functions to simplify filter writing.
parent 1ffbc2f1
......@@ -40,79 +40,29 @@ gst_gl_effects_blur_kernel (void)
return kernel;
}
static void
gst_gl_effects_blur_callback_hconv (gint width, gint height, guint texture,
gpointer data)
{
GstGLShader *shader = NULL;
GstGLEffects *effects = GST_GL_EFFECTS (data);
if (NULL != (shader = gst_gl_effects_get_fragment_shader (effects, "hconv0",
hconv7_fragment_source_gles2))) {
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (GST_GL_BASE_FILTER (filter)->context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_shader_set_uniform_1f (shader, "gauss_width", width);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7,
gst_gl_effects_blur_kernel ());
gst_gl_filter_draw_fullscreen_quad (filter);
}
}
static void
gst_gl_effects_blur_callback_vconv (gint width, gint height, guint texture,
gpointer data)
{
GstGLShader *shader = NULL;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
if (NULL != (shader = gst_gl_effects_get_fragment_shader (effects, "vconv0",
vconv7_fragment_source_gles2))) {
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (GST_GL_BASE_FILTER (filter)->context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_shader_set_uniform_1f (shader, "gauss_height", height);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7,
gst_gl_effects_blur_kernel ());
gst_gl_filter_draw_fullscreen_quad (filter);
}
}
void
gst_gl_effects_blur (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
gst_gl_filter_render_to_target (filter, TRUE, effects->intexture,
effects->midtexture[0], gst_gl_effects_blur_callback_hconv, effects);
gst_gl_filter_render_to_target (filter, FALSE, effects->midtexture[0],
effects->outtexture, gst_gl_effects_blur_callback_vconv, effects);
GstGLShader *shader;
shader = gst_gl_effects_get_fragment_shader (effects, "hconv0",
hconv7_fragment_source_gles2);
gst_gl_shader_use (shader);
gst_gl_shader_set_uniform_1f (shader, "gauss_width",
GST_VIDEO_INFO_WIDTH (&filter->in_info));
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7,
gst_gl_effects_blur_kernel ());
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->midtexture[0], shader);
shader = gst_gl_effects_get_fragment_shader (effects, "vconv0",
vconv7_fragment_source_gles2);
gst_gl_shader_use (shader);
gst_gl_shader_set_uniform_1f (shader, "gauss_height",
GST_VIDEO_INFO_HEIGHT (&filter->in_info));
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7,
gst_gl_effects_blur_kernel ());
gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[0],
effects->outtexture, shader);
}
......@@ -23,44 +23,14 @@
#include "../gstgleffects.h"
static void
gst_gl_effects_bulge_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
shader = gst_gl_effects_get_fragment_shader (effects, "bulge",
bulge_fragment_source_gles2);
if (!shader)
return;
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_filter_draw_fullscreen_quad (filter);
}
void
gst_gl_effects_bulge (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
gst_gl_filter_render_to_target (filter, TRUE, effects->intexture,
effects->outtexture, gst_gl_effects_bulge_callback, effects);
shader = gst_gl_effects_get_fragment_shader (effects, "bulge",
bulge_fragment_source_gles2);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->outtexture, shader);
}
......@@ -23,44 +23,14 @@
#include "../gstgleffects.h"
static void
gst_gl_effects_fisheye_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
shader = gst_gl_effects_get_fragment_shader (effects, "fisheye",
fisheye_fragment_source_gles2);
if (!shader)
return;
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_filter_draw_fullscreen_quad (filter);
}
void
gst_gl_effects_fisheye (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
gst_gl_filter_render_to_target (filter, TRUE, effects->intexture,
effects->outtexture, gst_gl_effects_fisheye_callback, effects);
shader = gst_gl_effects_get_fragment_shader (effects, "fisheye",
fisheye_fragment_source_gles2);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->outtexture, shader);
}
......@@ -26,170 +26,61 @@
static gboolean kernel_ready = FALSE;
static float gauss_kernel[7];
static void
gst_gl_effects_glow_step_one (gint width, gint height, guint texture,
gpointer data)
void
gst_gl_effects_glow (GstGLEffects * effects)
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
const GstGLFuncs *gl = GST_GL_BASE_FILTER (effects)->context->gl_vtable;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
shader = gst_gl_effects_get_fragment_shader (effects, "luma_threshold",
luma_threshold_fragment_source_gles2);
if (!shader)
return;
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_filter_draw_fullscreen_quad (filter);
}
static void
gst_gl_effects_glow_step_two (gint width, gint height, guint texture,
gpointer data)
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
shader = gst_gl_effects_get_fragment_shader (effects, "hconv7",
hconv7_fragment_source_gles2);
if (!shader)
return;
if (!kernel_ready) {
fill_gaussian_kernel (gauss_kernel, 7, 10.0);
kernel_ready = TRUE;
}
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE1);
gl->BindTexture (GL_TEXTURE_2D, texture);
/* threshold */
shader = gst_gl_effects_get_fragment_shader (effects, "luma_threshold",
luma_threshold_fragment_source_gles2);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->midtexture[0], shader);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
/* blur */
shader = gst_gl_effects_get_fragment_shader (effects, "hconv7",
hconv7_fragment_source_gles2);
gst_gl_shader_use (shader);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
gst_gl_shader_set_uniform_1f (shader, "gauss_width", width);
gst_gl_filter_draw_fullscreen_quad (filter);
}
static void
gst_gl_effects_glow_step_three (gint width, gint height, guint texture,
gpointer data)
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
gst_gl_shader_set_uniform_1f (shader, "gauss_width",
GST_VIDEO_INFO_WIDTH (&filter->out_info));
gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[0],
effects->midtexture[1], shader);
shader = gst_gl_effects_get_fragment_shader (effects, "vconv7",
vconv7_fragment_source_gles2);
if (!shader)
return;
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE1);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 1);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 7, gauss_kernel);
gst_gl_shader_set_uniform_1f (shader, "gauss_height", height);
gst_gl_filter_draw_fullscreen_quad (filter);
}
static void
gst_gl_effects_glow_step_four (gint width, gint height, guint texture,
gpointer data)
{
GstGLShader *shader;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
gst_gl_shader_set_uniform_1f (shader, "gauss_height",
GST_VIDEO_INFO_HEIGHT (&filter->out_info));
gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[1],
effects->midtexture[2], shader);
/* add blurred luma to intexture */
shader = gst_gl_effects_get_fragment_shader (effects, "sum",
sum_fragment_source_gles2);
if (!shader)
return;
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE2);
gl->BindTexture (GL_TEXTURE_2D, effects->intexture->tex_id);
gl->BindTexture (GL_TEXTURE_2D,
gst_gl_memory_get_texture_id (effects->intexture));
gst_gl_shader_set_uniform_1f (shader, "alpha", 1.0f);
gst_gl_shader_set_uniform_1i (shader, "base", 2);
gl->ActiveTexture (GL_TEXTURE1);
gl->BindTexture (GL_TEXTURE_2D, texture);
gl->BindTexture (GL_TEXTURE_2D,
gst_gl_memory_get_texture_id (effects->midtexture[2]));
gst_gl_shader_set_uniform_1f (shader, "beta", (gfloat) 1 / 3.5f);
gst_gl_shader_set_uniform_1i (shader, "blend", 1);
gst_gl_filter_draw_fullscreen_quad (filter);
}
void
gst_gl_effects_glow (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
/* threshold */
gst_gl_filter_render_to_target (filter, TRUE, effects->intexture,
effects->midtexture[0], gst_gl_effects_glow_step_one, effects);
/* blur */
gst_gl_filter_render_to_target (filter, FALSE, effects->midtexture[0],
effects->midtexture[1], gst_gl_effects_glow_step_two, effects);
gst_gl_filter_render_to_target (filter, FALSE, effects->midtexture[1],
effects->midtexture[2], gst_gl_effects_glow_step_three, effects);
/* add blurred luma to intexture */
gst_gl_filter_render_to_target (filter, FALSE, effects->midtexture[2],
effects->outtexture, gst_gl_effects_glow_step_four, effects);
gst_gl_filter_render_to_target_with_shader (filter, effects->midtexture[2],
effects->outtexture, shader);
}
......@@ -23,23 +23,13 @@
#include "../gstgleffects.h"
static void
gst_gl_effects_identity_callback (gint width, gint height, guint texture,
gpointer data)
void
gst_gl_effects_identity (GstGLEffects * effects)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLContext *context = GST_GL_BASE_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
GstGLShader *shader;
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
shader = g_hash_table_lookup (effects->shaderstable, "identity0");
if (!shader) {
GError *error = NULL;
......@@ -50,28 +40,10 @@ gst_gl_effects_identity_callback (gint width, gint height, guint texture,
return;
}
filter->draw_attr_position_loc =
gst_gl_shader_get_attribute_location (shader, "a_position");
filter->draw_attr_texture_loc =
gst_gl_shader_get_attribute_location (shader, "a_texcoord");
g_hash_table_insert (effects->shaderstable, (gchar *) "identity0", shader);
}
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_filter_draw_fullscreen_quad (filter);
}
void
gst_gl_effects_identity (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
gst_gl_filter_render_to_target (filter, TRUE, effects->intexture,
effects->outtexture, gst_gl_effects_identity_callback, effects);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->outtexture, shader);
}
......@@ -25,48 +25,28 @@
#include "../gstgleffects.h"
static void
gst_gl_effects_laplacian_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLShader *shader = NULL;
GstGLEffects *effects = GST_GL_EFFECTS (data);
GstGLFilter *filter = GST_GL_FILTER (effects);
if (NULL != (shader = gst_gl_effects_get_fragment_shader (effects, "conv0",
conv9_fragment_source_gles2))) {
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
static gfloat kernel[9] = { 0.0, -1.0, 0.0,
-1.0, 4.0, -1.0,
0.0, -1.0, 0.0
};
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (GST_GL_BASE_FILTER (filter)->context)) {
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
}
#endif
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_shader_set_uniform_1f (shader, "height", height);
gst_gl_shader_set_uniform_1f (shader, "width", width);
gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, kernel);
gst_gl_shader_set_uniform_1i (shader, "invert", effects->invert);
gst_gl_filter_draw_fullscreen_quad (filter);
}
}
static gfloat kernel[9] = {
0.0, -1.0, 0.0,
-1.0, 4.0, -1.0,
0.0, -1.0, 0.0
};
void
gst_gl_effects_laplacian (GstGLEffects * effects)
{
gst_gl_filter_render_to_target (GST_GL_FILTER (effects), TRUE,
effects->intexture, effects->outtexture,
gst_gl_effects_laplacian_callback, effects);
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLShader *shader;
shader = gst_gl_effects_get_fragment_shader (effects, "conv0",
conv9_fragment_source_gles2);
gst_gl_shader_use (shader);
gst_gl_shader_set_uniform_1f (shader, "height",
GST_VIDEO_INFO_HEIGHT (&filter->in_info));
gst_gl_shader_set_uniform_1f (shader, "width",
GST_VIDEO_INFO_WIDTH (&filter->in_info));
gst_gl_shader_set_uniform_1fv (shader, "kernel", 9, kernel);
gst_gl_shader_set_uniform_1i (shader, "invert", effects->invert);
gst_gl_filter_render_to_target_with_shader (filter, effects->intexture,
effects->outtexture, shader);
}
......@@ -26,13 +26,13 @@
void
gst_gl_effects_luma_to_curve (GstGLEffects * effects,
const GstGLEffectsCurve * curve,
gint curve_index, gint width, gint height, GLuint texture)
const GstGLEffectsCurve * curve, gint curve_index, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
GstGLShader *shader;
GstGLContext *context = GST_GL_BASE_FILTER (effects)->context;
GstGLFilter *filter = GST_GL_FILTER (effects);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
const GstGLFuncs *gl = context->gl_vtable;
GstGLShader *shader;
shader = gst_gl_effects_get_fragment_shader (effects, "luma_to_curve",
luma_to_curve_fragment_source_gles2);
......@@ -47,112 +47,46 @@ gst_gl_effects_luma_to_curve (GstGLEffects * effects,
}
#endif
gst_gl_shader_use (shader);
if (effects->curve[curve_index] == 0) {
/* this parameters are needed to have a right, predictable, mapping */
gl->GenTextures (1, &effects->curve[curve_index]);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
gl->BindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
gl->TexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
gl->TexImage1D (GL_TEXTURE_1D, 0, curve->bytes_per_pixel,
curve->width, 0, GL_RGB, GL_UNSIGNED_BYTE, curve->pixel_data);
}
#endif
if (USING_GLES2 (context) || USING_OPENGL3 (context)) {
gl->BindTexture (GL_TEXTURE_2D, effects->curve[curve_index]);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGB,
curve->width, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, curve->pixel_data);
}
}
gl->ActiveTexture (GL_TEXTURE2);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (shader, "tex", 2);
#if GST_GL_HAVE_OPENGL
if (USING_OPENGL (context)) {
gl->ActiveTexture (GL_TEXTURE1);
gl->BindTexture (GL_TEXTURE_1D, effects->curve[curve_index]);
gst_gl_shader_set_uniform_1i (shader, "curve", 1);
}
#endif
if (USING_GLES2 (context) || USING_OPENGL3 (context)) {
gl->ActiveTexture (GL_TEXTURE1);
gl->BindTexture (GL_TEXTURE_2D, effects->curve[curve_index]);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gst_gl_shader_set_uniform_1i (shader, "curve", 1);
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGB,
curve->width, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, curve->pixel_data);
}
gst_gl_filter_draw_fullscreen_quad (filter);
}
gst_gl_shader_use (shader);
gl->ActiveTexture (GL_TEXTURE2);
gl->BindTexture (GL_TEXTURE_2D, effects->curve[curve_index]);
static void
gst_gl_effects_heat_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
gst_gl_shader_set_uniform_1i (shader, "curve", 2);
gst_gl_effects_luma_to_curve (effects, &heat_curve, GST_GL_EFFECTS_CURVE_HEAT,
width, height, texture);
gst_gl_filter_render_to_target_with_shader (filter, in_tex, out_tex, shader);
}
void
gst_gl_effects_heat (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
gst_gl_filter_render_to_target (filter, TRUE, effects->intexture,
effects->outtexture, gst_gl_effects_heat_callback, effects);
}
static void
gst_gl_effects_sepia_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
gst_gl_effects_luma_to_curve (effects, &sepia_curve,
GST_GL_EFFECTS_CURVE_SEPIA, width, height, texture);
gst_gl_effects_luma_to_curve (effects, &heat_curve,
GST_GL_EFFECTS_CURVE_HEAT, effects->intexture, effects->outtexture);
}
void
gst_gl_effects_sepia (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
gst_gl_filter_render_to_target (filter, TRUE, effects->intexture,
effects->outtexture, gst_gl_effects_sepia_callback, effects);
}
static void
gst_gl_effects_luma_xpro_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLEffects *effects = GST_GL_EFFECTS (data);
gst_gl_effects_luma_to_curve (effects, &luma_xpro_curve,
GST_GL_EFFECTS_CURVE_LUMA_XPRO, width, height, texture);
gst_gl_effects_luma_to_curve (effects, &sepia_curve,
GST_GL_EFFECTS_CURVE_SEPIA, effects->intexture, effects->outtexture);
}
void
gst_gl_effects_luma_xpro (GstGLEffects * effects)
{
GstGLFilter *filter = GST_GL_FILTER (effects);
gst_gl_filter_render_to_target (filter, TRUE, effects->intexture,
effects->outtexture, gst_gl_effects_luma_xpro_callback, effects);
gst_gl_effects_luma_to_curve (effects, &luma_xpro_curve,
GST_GL_EFFECTS_CURVE_LUMA_XPRO, effects->intexture, effects->outtexture);
}
......@@ -28,8 +28,8 @@ G_BEGIN_DECLS
void gst_gl_effects_luma_to_curve (GstGLEffects *effects,
const GstGLEffectsCurve *curve,
gint curve_index,
gint width, gint height,
GLuint texture);
GstGLMemory *in_tex,
GstGLMemory *out_tex);
G_END_DECLS
#endif /* __GST_GL_LUMA_TO_CURVE_H__ */
......@@ -23,44 +23,14 @@
#include "../gstgleffects.h"
static void
gst_gl_effects_mirror_callback (gint width, gint height, guint texture,
gpointer data)
{
GstGLShader *shader;
GstGLFilter *filter = GST_GL_FILTER (data);
GstGLEffects *effects = GST_GL_EFFECTS (filter);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
shader = gst_gl_effects_get_fragment_shader (effects, "mirror",
mirror_fragment_source_gles2);
if (!shader)