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

gl: use GLMemory for accessing textures everywhere

This simplifies and consolidates a lot of duplicated code creating
and modifying textures.
parent c7dd43f2
......@@ -258,8 +258,8 @@ gst_gl_color_balance_callback (gint width, gint height, guint tex_id,
}
static gboolean
gst_gl_color_balance_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_color_balance_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
gst_gl_filter_render_to_target (filter, TRUE, in_tex, out_tex,
(GLCB) gst_gl_color_balance_callback, filter);
......
......@@ -74,7 +74,7 @@ static gboolean gst_gl_colorscale_gl_start (GstGLBaseFilter * base_filter);
static void gst_gl_colorscale_gl_stop (GstGLBaseFilter * base_filter);
static gboolean gst_gl_colorscale_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
static void
gst_gl_colorscale_class_init (GstGLColorscaleClass * klass)
......@@ -175,8 +175,8 @@ gst_gl_colorscale_gl_stop (GstGLBaseFilter * base_filter)
}
static gboolean
gst_gl_colorscale_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_colorscale_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
GstGLColorscale *colorscale = GST_GL_COLORSCALE (filter);
......
......@@ -64,7 +64,7 @@ static gboolean gst_gl_deinterlace_init_fbo (GstGLFilter * filter);
static gboolean gst_gl_deinterlace_filter (GstGLFilter * filter,
GstBuffer * inbuf, GstBuffer * outbuf);
static gboolean gst_gl_deinterlace_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
static void gst_gl_deinterlace_vfir_callback (gint width, gint height,
guint texture, gpointer stuff);
static void gst_gl_deinterlace_greedyh_callback (gint width, gint height,
......@@ -364,8 +364,8 @@ gst_gl_deinterlace_init_fbo (GstGLFilter * filter)
}
static gboolean
gst_gl_deinterlace_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_deinterlace_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (filter);
......
......@@ -62,7 +62,7 @@ static void gst_gl_differencematte_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static gboolean gst_gl_differencematte_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
static gboolean gst_gl_differencematte_loader (GstGLFilter * filter);
......@@ -79,22 +79,23 @@ gst_gl_differencematte_init_gl_resources (GstGLFilter * filter)
{
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
const GstGLFuncs *gl = context->gl_vtable;
GstGLBaseMemoryAllocator *tex_alloc;
GstGLAllocationParams *params;
GError *error = NULL;
gint i;
for (i = 0; i < 4; i++) {
gl->GenTextures (1, &differencematte->midtexture[i]);
gl->BindTexture (GL_TEXTURE_2D, differencematte->midtexture[i]);
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
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);
}
tex_alloc = (GstGLBaseMemoryAllocator *)
gst_gl_memory_allocator_get_default (context);
params =
(GstGLAllocationParams *) gst_gl_video_allocation_params_new (context,
NULL, &filter->out_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
for (i = 0; i < 4; i++)
differencematte->midtexture[i] =
(GstGLMemory *) gst_gl_base_memory_alloc (tex_alloc, params);
gst_gl_allocation_params_free (params);
gst_object_unref (tex_alloc);
if (!(differencematte->identity_shader =
gst_gl_shader_new_default (context, &error))) {
......@@ -165,11 +166,18 @@ static void
gst_gl_differencematte_reset_gl_resources (GstGLFilter * filter)
{
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
gint i;
gl->DeleteTextures (1, &differencematte->savedbgtexture);
gl->DeleteTextures (1, &differencematte->newbgtexture);
if (differencematte->savedbgtexture) {
gst_memory_unref (GST_MEMORY_CAST (differencematte->savedbgtexture));
differencematte->savedbgtexture = NULL;
}
if (differencematte->newbgtexture) {
gst_memory_unref (GST_MEMORY_CAST (differencematte->newbgtexture));
differencematte->newbgtexture = NULL;
}
for (i = 0; i < 4; i++) {
if (differencematte->identity_shader) {
gst_object_unref (differencematte->identity_shader);
......@@ -180,15 +188,14 @@ gst_gl_differencematte_reset_gl_resources (GstGLFilter * filter)
gst_object_unref (differencematte->shader[i]);
differencematte->shader[i] = NULL;
}
if (differencematte->midtexture[i]) {
gl->DeleteTextures (1, &differencematte->midtexture[i]);
differencematte->midtexture[i] = 0;
gst_memory_unref (GST_MEMORY_CAST (differencematte->midtexture[i]));
differencematte->midtexture[i] = NULL;
}
}
differencematte->location = NULL;
differencematte->pixbuf = NULL;
differencematte->savedbgtexture = 0;
differencematte->newbgtexture = 0;
differencematte->bg_has_changed = FALSE;
}
......@@ -277,38 +284,39 @@ gst_gl_differencematte_get_property (GObject * object, guint prop_id,
}
static void
init_pixbuf_texture (GstGLContext * context, gpointer data)
init_pixbuf_texture (GstGLDifferenceMatte * differencematte)
{
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (data);
GstGLFilter *filter = GST_GL_FILTER (data);
const GstGLFuncs *gl = context->gl_vtable;
guint internal_format =
gst_gl_sized_gl_format_from_gl_format_type (context, GL_RGBA,
GL_UNSIGNED_BYTE);
gl->DeleteTextures (1, &differencematte->newbgtexture);
gl->GenTextures (1, &differencematte->newbgtexture);
gl->BindTexture (GL_TEXTURE_2D, differencematte->newbgtexture);
gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format,
(gint) differencematte->pbuf_width, (gint) differencematte->pbuf_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, differencematte->pixbuf);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
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);
if (differencematte->savedbgtexture == 0) {
gl->GenTextures (1, &differencematte->savedbgtexture);
gl->BindTexture (GL_TEXTURE_2D, differencematte->savedbgtexture);
gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
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);
GstGLContext *context = GST_GL_BASE_FILTER (differencematte)->context;
GstGLFilter *filter = GST_GL_FILTER (differencematte);
GstGLBaseMemoryAllocator *tex_alloc;
GstGLAllocationParams *params;
GstVideoInfo v_info;
tex_alloc = (GstGLBaseMemoryAllocator *)
gst_gl_memory_allocator_get_default (context);
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA,
differencematte->pbuf_width, differencematte->pbuf_height);
params =
(GstGLAllocationParams *) gst_gl_video_allocation_params_new (context,
NULL, &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
differencematte->newbgtexture =
(GstGLMemory *) gst_gl_base_memory_alloc (tex_alloc, params);
gst_gl_allocation_params_free (params);
if (differencematte->savedbgtexture == NULL) {
params =
(GstGLAllocationParams *) gst_gl_video_allocation_params_new (context,
NULL, &filter->out_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
differencematte->savedbgtexture =
(GstGLMemory *) gst_gl_base_memory_alloc (tex_alloc, params);
gst_gl_allocation_params_free (params);
}
gst_object_unref (tex_alloc);
}
static void
......@@ -327,7 +335,7 @@ gst_gl_differencematte_diff (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1i (differencematte->shader[0], "current", 0);
gl->ActiveTexture (GL_TEXTURE1);
gl->BindTexture (GL_TEXTURE_2D, differencematte->savedbgtexture);
gl->BindTexture (GL_TEXTURE_2D, differencematte->savedbgtexture->tex_id);
gst_gl_shader_set_uniform_1i (differencematte->shader[0], "saved", 1);
......@@ -396,12 +404,12 @@ gst_gl_differencematte_interp (gint width, gint height, guint texture,
gst_gl_shader_set_uniform_1i (differencematte->shader[3], "blend", 0);
gl->ActiveTexture (GL_TEXTURE1);
gl->BindTexture (GL_TEXTURE_2D, differencematte->newbgtexture);
gl->BindTexture (GL_TEXTURE_2D, differencematte->newbgtexture->tex_id);
gst_gl_shader_set_uniform_1i (differencematte->shader[3], "base", 1);
gl->ActiveTexture (GL_TEXTURE2);
gl->BindTexture (GL_TEXTURE_2D, differencematte->midtexture[2]);
gl->BindTexture (GL_TEXTURE_2D, differencematte->midtexture[2]->tex_id);
gst_gl_shader_set_uniform_1i (differencematte->shader[3], "alpha", 2);
......@@ -427,8 +435,8 @@ gst_gl_differencematte_identity (gint width, gint height, guint texture,
}
static gboolean
gst_gl_differencematte_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_differencematte_filter_texture (GstGLFilter * filter,
GstGLMemory * in_tex, GstGLMemory * out_tex)
{
GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (filter);
......@@ -439,9 +447,7 @@ gst_gl_differencematte_filter_texture (GstGLFilter * filter, guint in_tex,
if (!gst_gl_differencematte_loader (filter))
differencematte->pixbuf = NULL;
/* if loader failed then context is turned off */
gst_gl_context_thread_add (GST_GL_BASE_FILTER (filter)->context,
init_pixbuf_texture, differencematte);
init_pixbuf_texture (differencematte);
/* save current frame, needed to calculate difference between
* this frame and next ones */
......@@ -457,7 +463,7 @@ gst_gl_differencematte_filter_texture (GstGLFilter * filter, guint in_tex,
differencematte->bg_has_changed = FALSE;
}
if (differencematte->savedbgtexture != 0) {
if (differencematte->savedbgtexture != NULL) {
gst_gl_filter_render_to_target (filter, TRUE, in_tex,
differencematte->midtexture[0], gst_gl_differencematte_diff,
differencematte);
......
......@@ -45,10 +45,10 @@ struct _GstGLDifferenceMatte
guchar *pixbuf;
gint pbuf_width, pbuf_height;
GLuint savedbgtexture;
GLuint newbgtexture;
GLuint midtexture[4];
GLuint intexture;
GstGLMemory *savedbgtexture;
GstGLMemory *newbgtexture;
GstGLMemory *midtexture[4];
GstGLMemory *intexture;
float kernel[7];
};
......
......@@ -71,7 +71,7 @@ static void gst_gl_effects_ghash_func_clean (gpointer key, gpointer value,
gpointer data);
static gboolean gst_gl_effects_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
static gboolean gst_gl_effects_filters_is_property_supported (const
GstGLEffectsFilterDescriptor *, gint property);
......@@ -274,31 +274,27 @@ gst_gl_effects_init_gl_resources (GstGLFilter * filter)
{
GstGLEffects *effects = GST_GL_EFFECTS (filter);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLFuncs *gl = context->gl_vtable;
guint internal_format;
gint i = 0;
GstGLBaseMemoryAllocator *base_alloc;
GstGLAllocationParams *params;
gint i;
for (i = 0; i < NEEDED_TEXTURES; i++) {
base_alloc = (GstGLBaseMemoryAllocator *)
gst_gl_memory_allocator_get_default (context);
params =
(GstGLAllocationParams *) gst_gl_video_allocation_params_new (context,
NULL, &filter->out_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA);
if (effects->midtexture[i]) {
gl->DeleteTextures (1, &effects->midtexture[i]);
effects->midtexture[i] = 0;
}
for (i = 0; i < NEEDED_TEXTURES; i++) {
if (effects->midtexture[i])
gst_memory_unref (GST_MEMORY_CAST (effects->midtexture[i]));
gl->GenTextures (1, &effects->midtexture[i]);
gl->BindTexture (GL_TEXTURE_2D, effects->midtexture[i]);
internal_format =
gst_gl_sized_gl_format_from_gl_format_type (context, GL_RGBA,
GL_UNSIGNED_BYTE);
gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info), 0, GL_RGBA, GL_UNSIGNED_BYTE,
NULL);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
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);
effects->midtexture[i] =
(GstGLMemory *) gst_gl_base_memory_alloc (base_alloc, params);
}
gst_object_unref (base_alloc);
gst_gl_allocation_params_free (params);
}
/* free resources that need a gl context */
......@@ -310,8 +306,7 @@ gst_gl_effects_reset_gl_resources (GstGLFilter * filter)
gint i = 0;
for (i = 0; i < NEEDED_TEXTURES; i++) {
gl->DeleteTextures (1, &effects->midtexture[i]);
effects->midtexture[i] = 0;
gst_memory_unref (GST_MEMORY_CAST (effects->midtexture[i]));
}
for (i = 0; i < GST_GL_EFFECTS_N_CURVES; i++) {
gl->DeleteTextures (1, &effects->curve[i]);
......@@ -396,10 +391,11 @@ gst_gl_effects_filter_class_init (GstGLEffectsClass * klass,
}
static void
set_horizontal_swap (GstGLContext * context, gpointer data)
set_horizontal_swap (GstGLEffects * effects)
{
#if GST_GL_HAVE_OPENGL
GstGLFuncs *gl = context->gl_vtable;
GstGLContext *context = GST_GL_BASE_FILTER (effects)->context;
const GstGLFuncs *gl = context->gl_vtable;
if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
const gfloat mirrormatrix[16] = {
......@@ -527,8 +523,8 @@ gst_gl_effects_on_init_gl_context (GstGLFilter * filter)
}
static gboolean
gst_gl_effects_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_effects_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
GstGLEffects *effects = GST_GL_EFFECTS (filter);
......@@ -536,8 +532,7 @@ gst_gl_effects_filter_texture (GstGLFilter * filter, guint in_tex,
effects->outtexture = out_tex;
if (effects->horizontal_swap == TRUE)
gst_gl_context_thread_add (GST_GL_BASE_FILTER (filter)->context,
set_horizontal_swap, effects);
set_horizontal_swap (effects);
effects->effect (effects);
......
......@@ -69,9 +69,9 @@ struct _GstGLEffects
GstGLEffectProcessFunc effect;
gint current_effect;
GLuint intexture;
GLuint midtexture[NEEDED_TEXTURES];
GLuint outtexture;
GstGLMemory *intexture;
GstGLMemory *midtexture[NEEDED_TEXTURES];
GstGLMemory *outtexture;
GLuint curve[GST_GL_EFFECTS_N_CURVES];
......
......@@ -69,7 +69,7 @@ static void gst_gl_filter_app_get_property (GObject * object, guint prop_id,
static gboolean gst_gl_filter_app_set_caps (GstGLFilter * filter,
GstCaps * incaps, GstCaps * outcaps);
static gboolean gst_gl_filter_app_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
static gboolean gst_gl_filter_app_gl_start (GstGLBaseFilter * base_filter);
static void gst_gl_filter_app_gl_stop (GstGLBaseFilter * base_filter);
......@@ -200,9 +200,8 @@ struct glcb2
{
GLCB func;
gpointer data;
guint texture;
guint width;
guint height;
GstGLMemory *in_tex;
GstGLMemory *out_tex;
};
/* convenience functions to simplify filter development */
......@@ -211,27 +210,28 @@ _glcb2 (gpointer data)
{
struct glcb2 *cb = data;
cb->func (cb->width, cb->height, cb->texture, cb->data);
cb->func (gst_gl_memory_get_texture_width (cb->in_tex),
gst_gl_memory_get_texture_height (cb->in_tex), cb->in_tex->tex_id,
cb->data);
}
static gboolean
gst_gl_filter_app_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_filter_app_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
GstGLFilterApp *app_filter = GST_GL_FILTER_APP (filter);
struct glcb2 cb;
cb.func = (GLCB) _emit_draw_signal;
cb.data = filter;
cb.texture = in_tex;
cb.width = GST_VIDEO_INFO_WIDTH (&filter->in_info);
cb.height = GST_VIDEO_INFO_HEIGHT (&filter->in_info);
cb.in_tex = in_tex;
cb.out_tex = out_tex;
//blocking call, use a FBO
gst_gl_context_use_fbo_v2 (GST_GL_BASE_FILTER (filter)->context,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
filter->fbo, filter->depthbuffer, out_tex, _glcb2, &cb);
filter->fbo, filter->depthbuffer, out_tex->tex_id, _glcb2, &cb);
if (app_filter->default_draw) {
gst_gl_filter_render_to_target_with_shader (filter, TRUE, in_tex, out_tex,
......
......@@ -81,7 +81,7 @@ static void gst_gl_filter_cube_reset_gl (GstGLFilter * filter);
static gboolean gst_gl_filter_cube_init_shader (GstGLFilter * filter);
static void _callback (gpointer stuff);
static gboolean gst_gl_filter_cube_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
/* vertex source */
static const gchar *cube_v_src =
......@@ -335,8 +335,8 @@ gst_gl_filter_cube_init_shader (GstGLFilter * filter)
}
static gboolean
gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_filter_cube_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
......@@ -346,7 +346,7 @@ gst_gl_filter_cube_filter_texture (GstGLFilter * filter, guint in_tex,
gst_gl_context_use_fbo_v2 (GST_GL_BASE_FILTER (filter)->context,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info), filter->fbo,
filter->depthbuffer, out_tex, _callback, (gpointer) cube_filter);
filter->depthbuffer, out_tex->tex_id, _callback, (gpointer) cube_filter);
return TRUE;
}
......@@ -466,7 +466,7 @@ _callback (gpointer stuff)
gst_gl_shader_use (cube_filter->shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, cube_filter->in_tex);
gl->BindTexture (GL_TEXTURE_2D, cube_filter->in_tex->tex_id);
gst_gl_shader_set_uniform_1i (cube_filter->shader, "s_texture", 0);
gst_gl_shader_set_uniform_1f (cube_filter->shader, "xrot_degree", xrot);
gst_gl_shader_set_uniform_1f (cube_filter->shader, "yrot_degree", yrot);
......
......@@ -40,6 +40,7 @@ struct _GstGLFilterCube
GstGLFilter filter;
GstGLShader *shader;
GstGLMemory *in_tex;
/* background color */
gfloat red;
......@@ -52,7 +53,6 @@ struct _GstGLFilterCube
gdouble znear;
gdouble zfar;
guint in_tex;
GLuint vao;
GLuint vbo_indices;
GLuint vertex_buffer;
......
......@@ -66,7 +66,7 @@ static gboolean gst_gl_filter_glass_reset (GstBaseTransform * trans);
static gboolean gst_gl_filter_glass_init_shader (GstGLFilter * filter);
static gboolean gst_gl_filter_glass_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
static void gst_gl_filter_glass_draw_background_gradient ();
static void gst_gl_filter_glass_draw_video_plane (GstGLFilter * filter,
......@@ -238,17 +238,18 @@ gst_gl_filter_glass_init_shader (GstGLFilter * filter)
}
static gboolean
gst_gl_filter_glass_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_filter_glass_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (filter);
glass_filter->in_tex = in_tex;
//blocking call, use a FBO
gst_gl_context_use_fbo_v2 (GST_GL_BASE_FILTER (filter)->context,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
filter->fbo, filter->depthbuffer, out_tex,
filter->fbo, filter->depthbuffer, out_tex->tex_id,
gst_gl_filter_glass_callback, (gpointer) glass_filter);
return TRUE;
......@@ -365,7 +366,7 @@ gst_gl_filter_glass_callback (gpointer stuff)
gint width = GST_VIDEO_INFO_WIDTH (&filter->out_info);
gint height = GST_VIDEO_INFO_HEIGHT (&filter->out_info);
guint texture = glass_filter->in_tex;
guint texture = glass_filter->in_tex->tex_id;
if (start_time == 0)
start_time = get_time ();
......
......@@ -41,7 +41,8 @@ struct _GstGLFilterGlass
GstGLShader *passthrough_shader;
GstGLShader *shader;
gint64 timestamp;
guint in_tex;
GstGLMemory *in_tex;
GstGLMemory *out_tex;
};
struct _GstGLFilterGlassClass
......
......@@ -82,7 +82,7 @@ static void gst_gl_filtershader_gl_stop (GstGLBaseFilter * base);
static gboolean gst_gl_filtershader_filter (GstGLFilter * filter,
GstBuffer * inbuf, GstBuffer * outbuf);
static gboolean gst_gl_filtershader_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
static void gst_gl_filtershader_hcallback (gint width, gint height,
guint texture, gpointer stuff);
......@@ -313,8 +313,8 @@ gst_gl_filtershader_filter (GstGLFilter * filter, GstBuffer * inbuf,
}
static gboolean
gst_gl_filtershader_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_filtershader_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter);
......
......@@ -631,7 +631,7 @@ _upload_frames (GstAggregator * agg, GstAggregatorPad * agg_pad,
gboolean
gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
{
guint out_tex;
GstGLMemory *out_tex;
gboolean res = TRUE;
GstVideoFrame out_frame;
GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (mix);
......@@ -645,7 +645,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
return FALSE;
}
out_tex = *(guint *) out_frame.data[0];
out_tex = (GstGLMemory *) out_frame.map[0].memory;
if (!gst_aggregator_iterate_sinkpads (GST_AGGREGATOR (mix),
(GstAggregatorPadForeachFunc) _upload_frames, NULL))
......
......@@ -78,7 +78,7 @@ typedef gboolean (*GstGLMixerSetCaps) (GstGLMixer* mixer,
GstCaps* outcaps);
typedef void (*GstGLMixerReset) (GstGLMixer *mixer);
typedef gboolean (*GstGLMixerProcessFunc) (GstGLMixer *mix, GstBuffer *outbuf);
typedef gboolean (*GstGLMixerProcessTextures) (GstGLMixer *mix, guint out_tex);
typedef gboolean (*GstGLMixerProcessTextures) (GstGLMixer *mix, GstGLMemory *out_tex);
struct _GstGLMixer
{
......
......@@ -70,7 +70,7 @@ static gboolean gst_gl_mosaic_init_shader (GstGLMixer * mixer,
GstCaps * outcaps);
static gboolean gst_gl_mosaic_process_textures (GstGLMixer * mixer,
guint out_tex);
GstGLMemory * out_tex);
static void gst_gl_mosaic_callback (gpointer stuff);
//vertex source
......@@ -194,7 +194,7 @@ gst_gl_mosaic_init_shader (GstGLMixer * mixer, GstCaps * outcaps)
}
static gboolean
gst_gl_mosaic_process_textures (GstGLMixer * mix, guint out_tex)
gst_gl_mosaic_process_textures (GstGLMixer * mix, GstGLMemory * out_tex)
{
GstGLMosaic *mosaic = GST_GL_MOSAIC (mix);
......@@ -202,7 +202,8 @@ gst_gl_mosaic_process_textures (GstGLMixer * mix, guint out_tex)
gst_gl_context_use_fbo_v2 (GST_GL_BASE_MIXER (mix)->context,
GST_VIDEO_INFO_WIDTH (&GST_VIDEO_AGGREGATOR (mix)->info),
GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_AGGREGATOR (mix)->info), mix->fbo,
mix->depthbuffer, out_tex, gst_gl_mosaic_callback, (gpointer) mosaic);
mix->depthbuffer, out_tex->tex_id, gst_gl_mosaic_callback,
(gpointer) mosaic);
return TRUE;
}
......
......@@ -40,6 +40,7 @@ struct _GstGLMosaic
GstGLMixer mixer;
GstGLShader *shader;
GstGLMemory *out_tex;
};
struct _GstGLMosaicClass
......
......@@ -72,7 +72,7 @@ static void gst_gl_overlay_get_property (GObject * object, guint prop_id,
static void gst_gl_overlay_before_transform (GstBaseTransform * trans,
GstBuffer * outbuf);
static gboolean gst_gl_overlay_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
static gboolean gst_gl_overlay_load_png (GstGLOverlay * overlay, FILE * fp);
static gboolean gst_gl_overlay_load_jpeg (GstGLOverlay * overlay, FILE * fp);
......@@ -624,8 +624,8 @@ out:
}
static gboolean
gst_gl_overlay_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_overlay_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
GstGLMemory * out_tex)
{
GstGLOverlay *overlay = GST_GL_OVERLAY (filter);
......
......@@ -107,7 +107,7 @@ gst_gl_transformation_prepare_output_buffer (GstBaseTransform * trans,
static gboolean gst_gl_transformation_filter (GstGLFilter * filter,
GstBuffer * inbuf, GstBuffer * outbuf);
static gboolean gst_gl_transformation_filter_texture (GstGLFilter * filter,
guint in_tex, guint out_tex);
GstGLMemory * in_tex, GstGLMemory * out_tex);
static void
gst_gl_transformation_class_init (GstGLTransformationClass * klass)
......@@ -782,8 +782,8 @@ gst_gl_transformation_filter (GstGLFilter * filter,
}
static gboolean
gst_gl_transformation_filter_texture (GstGLFilter * filter, guint in_tex,
guint out_tex)
gst_gl_transformation_filter_texture (GstGLFilter * filter,
GstGLMemory * in_tex, GstGLMemory * out_tex)
{
GstGLTransformation *transformation = GST_GL_TRANSFORMATION (filter);
......@@ -794,7 +794,8 @@ gst_gl_transformation_filter_texture (GstGLFilter * filter, guint in_tex,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
filter->fbo, filter->depthbuffer,
out_tex, gst_gl_transformation_callback, (gpointer) transformation);
out_tex->tex_id, gst_gl_transformation_callback,
(gpointer) transformation);
return TRUE;
}
......@@ -874,7 +875,7 @@ gst_gl_transformation_callback (gpointer stuff)
gst_gl_shader_use (transformation->shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, transformation->in_tex);
gl->BindTexture (GL_TEXTURE_2D, transformation->in_tex->tex_id);
gst_gl_shader_set_uniform_1i (transformation->shader, "texture", 0);
graphene_matrix_to_float (&transformation->mvp_matrix, temp_matrix);
......
......@@ -47,7 +47,8 @@ struct _GstGLTransformation
GLint attr_position;
GLint attr_texture;
guint in_tex;
GstGLMemory *in_tex;
GstGLMemory *out_tex;
gfloat xrotation;
gfloat yrotation;
......
......@@ -474,7 +474,7 @@ static gboolean gst_gl_video_mixer_init_shader (GstGLMixer * mixer,
GstCaps * outcaps);
static gboolean gst_gl_video_mixer_process_textures (GstGLMixer * mixer,
guint out_tex);