*** gstgloverlay_old.c	2009-08-12 18:17:37.000000000 +0200
--- gstgloverlay.c	2009-08-12 18:25:44.000000000 +0200
***************
*** 55,64 ****
    gchar *location;
    gboolean pbuf_has_changed;
  
!   guchar *pixbuf;
!   gint width, height;
!   GLuint pbuftexture;
! 
  //  gboolean stretch;
  };
  
--- 55,66 ----
    gchar *location;
    gboolean pbuf_has_changed;
  
!   guchar	*pixbuf;
!   gint		width, height;
!   GLuint	pbuftexture;
!   gint8		pos_x;
!   gint8		pos_y;
!   guint8       	size;
  //  gboolean stretch;
  };
  
***************
*** 102,108 ****
  {
    PROP_0,
    PROP_LOCATION,
! //  PROP_STRETCH,
    /* future properties? */
    /* PROP_WIDTH, */
    /* PROP_HEIGHT, */
--- 104,113 ----
  {
    PROP_0,
    PROP_LOCATION,
!   PROP_XPOS,
!   PROP_YPOS,
!   PROP_SIZE
!   //  PROP_STRETCH,
    /* future properties? */
    /* PROP_WIDTH, */
    /* PROP_HEIGHT, */
***************
*** 155,162 ****
    g_object_class_install_property (gobject_class,
        PROP_LOCATION,
        g_param_spec_string ("location",
!           "Location of the image",
!           "Location of the image", NULL, G_PARAM_READWRITE));
    /*
       g_object_class_install_property (gobject_class,
       PROP_STRETCH,
--- 160,185 ----
    g_object_class_install_property (gobject_class,
        PROP_LOCATION,
        g_param_spec_string ("location",
!           "Image file location",
!           "Image file location", 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,
       PROP_STRETCH,
***************
*** 171,194 ****
  gst_gl_overlay_draw_texture (GstGLOverlay * overlay, GLuint tex)
  {
    GstGLFilter *filter = GST_GL_FILTER (overlay);
! 
    gfloat width = (gfloat) filter->width;
    gfloat height = (gfloat) filter->height;
! 
    glActiveTexture (GL_TEXTURE0);
    glEnable (GL_TEXTURE_RECTANGLE_ARB);
    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
! 
    glBegin (GL_QUADS);
! 
!   glTexCoord2f (0.0, 0.0);
!   glVertex2f (-1.0, -1.0);
!   glTexCoord2f (width, 0.0);
!   glVertex2f (1.0, -1.0);
!   glTexCoord2f (width, height);
!   glVertex2f (1.0, 1.0);
!   glTexCoord2f (0.0, height);
!   glVertex2f (-1.0, 1.0);
  
    glEnd ();
  
--- 194,219 ----
  gst_gl_overlay_draw_texture (GstGLOverlay * overlay, GLuint tex)
  {
    GstGLFilter *filter = GST_GL_FILTER (overlay);
!   gfloat posx = 0.0;
!   gfloat posy = 0.0;
!   gfloat size = 0.0;
    gfloat width = (gfloat) filter->width;
    gfloat height = (gfloat) filter->height;
!   
    glActiveTexture (GL_TEXTURE0);
    glEnable (GL_TEXTURE_RECTANGLE_ARB);
    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
!  
    glBegin (GL_QUADS);
!   
!   glTexCoord2f(0.0, 0.0);
!   glVertex2f(-1.0, -1.0);
!   glTexCoord2f(width, 0.0);
!   glVertex2f(1.0, -1.0);
!   glTexCoord2f(width, height);
!   glVertex2f(1.0, 1.0);
!   glTexCoord2f(0.0, height);
!   glVertex2f(-1.0, 1.0);
  
    glEnd ();
  
***************
*** 205,222 ****
  
    glEnable (GL_TEXTURE_RECTANGLE_ARB);
    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, overlay->pbuftexture);
- 
    glBegin (GL_QUADS);
! 
    glTexCoord2f (0.0, 0.0);
!   glVertex2f (-1.0, -1.0);
    glTexCoord2f (width, 0.0);
!   glVertex2f (1.0, -1.0);
    glTexCoord2f (width, height);
!   glVertex2f (1.0, 1.0);
    glTexCoord2f (0.0, height);
!   glVertex2f (-1.0, 1.0);
! 
    glEnd ();
  
  
--- 230,251 ----
  
    glEnable (GL_TEXTURE_RECTANGLE_ARB);
    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, overlay->pbuftexture);
    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);
!   glVertex2f (posx - (size / 2), posy - (size / 2)); //haut gauche // 0.1 = %donne par user / resolution
    glTexCoord2f (width, 0.0);
!   glVertex2f (posx + (size / 2), posy - (size / 2)); // haut droite
    glTexCoord2f (width, height);
!   glVertex2f (posx + (size / 2), posy + (size / 2)); // bas droite
    glTexCoord2f (0.0, height);
!   glVertex2f (posx - (size / 2), posy + (size / 2)); // bas gauche
    glEnd ();
  
  
***************
*** 232,237 ****
--- 261,269 ----
    overlay->pbuftexture = 0;
    overlay->width = 0;
    overlay->height = 0;
+   overlay->pos_x = 0.0;
+   overlay->pos_y = 0.0;
+   overlay->size = 100;
  //  overlay->stretch = TRUE;
    overlay->pbuf_has_changed = FALSE;
  }
***************
*** 248,264 ****
  {
    GstGLOverlay *overlay = GST_GL_OVERLAY (object);
  
!   switch (prop_id) {
      case PROP_LOCATION:
        if (overlay->location != NULL)
          g_free (overlay->location);
        overlay->pbuf_has_changed = TRUE;
        overlay->location = g_value_dup_string (value);
        break;
! /*  case PROP_STRETCH:
!     overlay->stretch = g_value_get_boolean (value);
!     break;
! */
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
--- 280,306 ----
  {
    GstGLOverlay *overlay = GST_GL_OVERLAY (object);
  
!   switch (prop_id) 
!     {
      case PROP_LOCATION:
        if (overlay->location != NULL)
          g_free (overlay->location);
        overlay->pbuf_has_changed = TRUE;
        overlay->location = g_value_dup_string (value);
        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:
! 	overlay->stretch = g_value_get_boolean (value);
! 	break;
!     */
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
***************
*** 275,281 ****
      case PROP_LOCATION:
        g_value_set_string (value, overlay->location);
        break;
! /*  case PROP_STRETCH:
      g_value_set_boolean (value, overlay->stretch);
      break;
  */
--- 317,332 ----
      case PROP_LOCATION:
        g_value_set_string (value, overlay->location);
        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:
      g_value_set_boolean (value, overlay->stretch);
      break;
  */
***************
*** 334,340 ****
--- 385,393 ----
      gst_gl_display_thread_add (filter->display, init_pixbuf_texture, overlay);
  
      if (overlay->pixbuf) {
+       /***********************/
        free (overlay->pixbuf);
+       /***********************/
        overlay->pixbuf = NULL;
      }
  
***************
*** 408,428 ****
      png_destroy_read_struct (&png_ptr, png_infopp_NULL, png_infopp_NULL);
      LOAD_ERROR ("color type is not rgb");
    }
- 
    overlay->width = width;
    overlay->height = height;
- 
    overlay->pixbuf = (guchar *) malloc (sizeof (guchar) * width * height * 4);
- 
    rows = (guchar **) malloc (sizeof (guchar *) * height);
- 
    for (y = 0; y < height; ++y)
      rows[y] = (guchar *) (overlay->pixbuf + y * width * 4);
- 
    png_read_image (png_ptr, rows);
- 
    free (rows);
- 
    png_read_end (png_ptr, info_ptr);
    png_destroy_read_struct (&png_ptr, &info_ptr, png_infopp_NULL);
    fclose (fp);
--- 461,474 ----
