ximagesrc: change from XGetImage to XGetSubImage dependant on a property

ximagesrc: change from XGetImage to XGetSubImage dependant on a property
 to avoid unnecessary performance hits by default.
This commit is contained in:
Vincent Penquerc'h 2010-11-29 12:36:06 +00:00 committed by Sebastian Dröge
parent ac872f61cf
commit 7ac31b3d22
2 changed files with 35 additions and 4 deletions

View file

@ -69,7 +69,8 @@ enum
PROP_STARTX, PROP_STARTX,
PROP_STARTY, PROP_STARTY,
PROP_ENDX, PROP_ENDX,
PROP_ENDY PROP_ENDY,
PROP_REMOTE,
}; };
GST_BOILERPLATE (GstXImageSrc, gst_ximage_src, GstPushSrc, GST_TYPE_PUSH_SRC); GST_BOILERPLATE (GstXImageSrc, gst_ximage_src, GstPushSrc, GST_TYPE_PUSH_SRC);
@ -591,9 +592,16 @@ gst_ximage_src_ximage_get (GstXImageSrc * ximagesrc)
#endif /* HAVE_XSHM */ #endif /* HAVE_XSHM */
{ {
GST_DEBUG_OBJECT (ximagesrc, "Retrieving screen using XGetImage"); GST_DEBUG_OBJECT (ximagesrc, "Retrieving screen using XGetImage");
XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow, if (ximagesrc->remote) {
ximagesrc->startx, ximagesrc->starty, ximagesrc->width, XGetSubImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
ximagesrc->height, AllPlanes, ZPixmap, ximage->ximage, 0, 0); ximagesrc->startx, ximagesrc->starty, ximagesrc->width,
ximagesrc->height, AllPlanes, ZPixmap, ximage->ximage, 0, 0);
} else {
ximage->ximage =
XGetImage (ximagesrc->xcontext->disp, ximagesrc->xwindow,
ximagesrc->startx, ximagesrc->starty, ximagesrc->width,
ximagesrc->height, AllPlanes, ZPixmap);
}
} }
#ifdef HAVE_XDAMAGE #ifdef HAVE_XDAMAGE
} }
@ -824,6 +832,9 @@ gst_ximage_src_set_property (GObject * object, guint prop_id,
case PROP_ENDY: case PROP_ENDY:
src->endy = g_value_get_uint (value); src->endy = g_value_get_uint (value);
break; break;
case PROP_REMOTE:
src->remote = g_value_get_boolean (value);
break;
default: default:
break; break;
} }
@ -864,6 +875,9 @@ gst_ximage_src_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_ENDY: case PROP_ENDY:
g_value_set_uint (value, src->endy); g_value_set_uint (value, src->endy);
break; break;
case PROP_REMOTE:
g_value_set_uint (value, src->remote);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -1110,6 +1124,19 @@ gst_ximage_src_class_init (GstXImageSrcClass * klass)
"Y coordinate of bottom right corner of area to be recorded (0 for bottom right of screen)", "Y coordinate of bottom right corner of area to be recorded (0 for bottom right of screen)",
0, G_MAXINT, 0, G_PARAM_READWRITE)); 0, G_MAXINT, 0, G_PARAM_READWRITE));
/**
* GstXImageSrc:remote
*
* Whether the X display is remote. The element will try to use alternate calls
* known to work better with remote displays.
*
* Since: 0.10.26
**/
g_object_class_install_property (gc, PROP_REMOTE,
g_param_spec_boolean ("remote", "Remote dispay",
"Whether the display is remote", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
push_class->create = gst_ximage_src_create; push_class->create = gst_ximage_src_create;
@ -1136,6 +1163,7 @@ gst_ximage_src_init (GstXImageSrc * ximagesrc, GstXImageSrcClass * klass)
ximagesrc->starty = 0; ximagesrc->starty = 0;
ximagesrc->endx = 0; ximagesrc->endx = 0;
ximagesrc->endy = 0; ximagesrc->endy = 0;
ximagesrc->remote = FALSE;
} }
static gboolean static gboolean

View file

@ -83,6 +83,9 @@ struct _GstXImageSrc
guint endx; guint endx;
guint endy; guint endy;
/* whether to use remote friendly calls */
gboolean remote;
#ifdef HAVE_XFIXES #ifdef HAVE_XFIXES
int fixes_event_base; int fixes_event_base;
XFixesCursorImage *cursor_image; XFixesCursorImage *cursor_image;