mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-19 12:45:54 +00:00
[375/906] gloverlay: can control image size and position
Fix bug #591591
This commit is contained in:
parent
586604e2e6
commit
a86d07acca
2 changed files with 64 additions and 10 deletions
|
@ -73,12 +73,9 @@ enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_LOCATION,
|
PROP_LOCATION,
|
||||||
// PROP_STRETCH,
|
PROP_XPOS,
|
||||||
/* future properties? */
|
PROP_YPOS,
|
||||||
/* PROP_WIDTH, */
|
PROP_SIZE
|
||||||
/* PROP_HEIGHT, */
|
|
||||||
/* PROP_XPOS, */
|
|
||||||
/* PROP_YPOS */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,6 +125,26 @@ gst_gl_overlay_class_init (GstGLOverlayClass * klass)
|
||||||
g_param_spec_string ("location",
|
g_param_spec_string ("location",
|
||||||
"Location of the image",
|
"Location of the image",
|
||||||
"Location of the image", NULL, G_PARAM_READWRITE));
|
"Location of the image", NULL, G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_XPOS,
|
||||||
|
g_param_spec_int ("xpos",
|
||||||
|
"X position of overlay image in percents",
|
||||||
|
"X position of overlay image in percents",
|
||||||
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_YPOS,
|
||||||
|
g_param_spec_int ("ypos",
|
||||||
|
"Y position of overlay image in percents",
|
||||||
|
"Y position of overlay image in percents",
|
||||||
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_SIZE,
|
||||||
|
g_param_spec_int ("proportion",
|
||||||
|
"Relative size of overlay image, in percents",
|
||||||
|
"Relative size of iverlay image, in percents",
|
||||||
|
0, 100, 0, G_PARAM_READWRITE));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_STRETCH,
|
PROP_STRETCH,
|
||||||
|
@ -143,6 +160,9 @@ gst_gl_overlay_draw_texture (GstGLOverlay * overlay, GLuint tex)
|
||||||
{
|
{
|
||||||
GstGLFilter *filter = GST_GL_FILTER (overlay);
|
GstGLFilter *filter = GST_GL_FILTER (overlay);
|
||||||
|
|
||||||
|
gfloat posx = 0.0;
|
||||||
|
gfloat posy = 0.0;
|
||||||
|
gfloat size = 0.0;
|
||||||
gfloat width = (gfloat) filter->width;
|
gfloat width = (gfloat) filter->width;
|
||||||
gfloat height = (gfloat) filter->height;
|
gfloat height = (gfloat) filter->height;
|
||||||
|
|
||||||
|
@ -179,14 +199,24 @@ gst_gl_overlay_draw_texture (GstGLOverlay * overlay, GLuint tex)
|
||||||
|
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
|
||||||
|
size = (overlay->size) / 50.0;
|
||||||
|
posx = (overlay->pos_x - 50.0) / 50.0;
|
||||||
|
posx =
|
||||||
|
(posx - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posx + (size / 2) >
|
||||||
|
1.00) ? (1.0 - size / 2) : posx;
|
||||||
|
posy = (overlay->pos_y - 50.0) / 50.0;
|
||||||
|
posy =
|
||||||
|
(posy - (size / 2) < -1.00) ? (-1.0 + size / 2) : (posy + (size / 2) >
|
||||||
|
1.00) ? (1.0 - size / 2) : posy;
|
||||||
|
|
||||||
glTexCoord2f (0.0, 0.0);
|
glTexCoord2f (0.0, 0.0);
|
||||||
glVertex2f (-1.0, -1.0);
|
glVertex2f (posx - (size / 2), posy - (size / 2));
|
||||||
glTexCoord2f (width, 0.0);
|
glTexCoord2f (width, 0.0);
|
||||||
glVertex2f (1.0, -1.0);
|
glVertex2f (posx + (size / 2), posy - (size / 2));
|
||||||
glTexCoord2f (width, height);
|
glTexCoord2f (width, height);
|
||||||
glVertex2f (1.0, 1.0);
|
glVertex2f (posx + (size / 2), posy + (size / 2));
|
||||||
glTexCoord2f (0.0, height);
|
glTexCoord2f (0.0, height);
|
||||||
glVertex2f (-1.0, 1.0);
|
glVertex2f (posx - (size / 2), posy + (size / 2));
|
||||||
|
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
|
||||||
|
@ -203,6 +233,9 @@ gst_gl_overlay_init (GstGLOverlay * overlay, GstGLOverlayClass * klass)
|
||||||
overlay->pbuftexture = 0;
|
overlay->pbuftexture = 0;
|
||||||
overlay->width = 0;
|
overlay->width = 0;
|
||||||
overlay->height = 0;
|
overlay->height = 0;
|
||||||
|
overlay->pos_x = 0.0;
|
||||||
|
overlay->pos_y = 0.0;
|
||||||
|
overlay->size = 100;
|
||||||
// overlay->stretch = TRUE;
|
// overlay->stretch = TRUE;
|
||||||
overlay->pbuf_has_changed = FALSE;
|
overlay->pbuf_has_changed = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -226,6 +259,15 @@ gst_gl_overlay_set_property (GObject * object, guint prop_id,
|
||||||
overlay->pbuf_has_changed = TRUE;
|
overlay->pbuf_has_changed = TRUE;
|
||||||
overlay->location = g_value_dup_string (value);
|
overlay->location = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_XPOS:
|
||||||
|
overlay->pos_x = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_YPOS:
|
||||||
|
overlay->pos_y = g_value_get_int (value);
|
||||||
|
break;
|
||||||
|
case PROP_SIZE:
|
||||||
|
overlay->size = g_value_get_int (value);
|
||||||
|
break;
|
||||||
/* case PROP_STRETCH:
|
/* case PROP_STRETCH:
|
||||||
overlay->stretch = g_value_get_boolean (value);
|
overlay->stretch = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
@ -246,6 +288,15 @@ gst_gl_overlay_get_property (GObject * object, guint prop_id,
|
||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
g_value_set_string (value, overlay->location);
|
g_value_set_string (value, overlay->location);
|
||||||
break;
|
break;
|
||||||
|
case PROP_XPOS:
|
||||||
|
g_value_set_int (value, overlay->pos_x);
|
||||||
|
break;
|
||||||
|
case PROP_YPOS:
|
||||||
|
g_value_set_int (value, overlay->pos_y);
|
||||||
|
break;
|
||||||
|
case PROP_SIZE:
|
||||||
|
g_value_set_int (value, overlay->size);
|
||||||
|
break;
|
||||||
/* case PROP_STRETCH:
|
/* case PROP_STRETCH:
|
||||||
g_value_set_boolean (value, overlay->stretch);
|
g_value_set_boolean (value, overlay->stretch);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -40,6 +40,9 @@ struct _GstGLOverlay
|
||||||
gchar *location;
|
gchar *location;
|
||||||
gboolean pbuf_has_changed;
|
gboolean pbuf_has_changed;
|
||||||
|
|
||||||
|
gint8 pos_x;
|
||||||
|
gint8 pos_y;
|
||||||
|
guint8 size;
|
||||||
guchar *pixbuf;
|
guchar *pixbuf;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
GLuint pbuftexture;
|
GLuint pbuftexture;
|
||||||
|
|
Loading…
Reference in a new issue