add [Get/Put]Video and [Get/Put]Still support

* hw/kdrive/ephyr/ephyrhostvideo.c,h:
	  (ephyrHostXVAdaptorHasXXX): fix these.
	  (ephyrHostXVAdaptorHasGetVideo): added this
	  (ephyrHostXVAdaptorHasGetStill): ditto
	  (ephyrHostXVPutVideo): added this
	  (ephyrHostXVGetVideo): ditto
	  (ephyrHostXVPutStill): ditto
	  (ephyrHostXVGetStill): ditto
	* hw/kdrive/ephyr/ephyrvideo.c:
	  (ephyrPutVideo): implement this
	  (ephyrGetVideo): ditto
	  (ephyrPutStill): ditto
	  (ephyrGetStill): ditto
	  (ephyrXVPrivSetAdaptorsHooks): advertise GetVideo and GetStill
	  when the host X supports it.
This commit is contained in:
Dodji Seketeli 2007-08-07 14:16:13 +02:00
parent 6f7961bc21
commit 4ed083095a
3 changed files with 452 additions and 54 deletions

View File

@ -370,7 +370,18 @@ ephyrHostXVAdaptorHasPutVideo (const EphyrHostXVAdaptor *a_this,
{
EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
if (((XvAdaptorInfo*)a_this)->type & XvVideoMask)
if (((XvAdaptorInfo*)a_this)->type & XvVideoMask & XvInputMask)
*a_result = TRUE ;
else
*a_result = FALSE ;
return TRUE ;
}
Bool
ephyrHostXVAdaptorHasGetVideo (const EphyrHostXVAdaptor *a_this,
Bool *a_result)
{
if (((XvAdaptorInfo*)a_this)->type & XvVideoMask & XvOutputMask)
*a_result = TRUE ;
else
*a_result = FALSE ;
@ -383,7 +394,20 @@ ephyrHostXVAdaptorHasPutStill (const EphyrHostXVAdaptor *a_this,
{
EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
if (((XvAdaptorInfo*)a_this)->type & XvStillMask)
if (((XvAdaptorInfo*)a_this)->type & XvStillMask && XvInputMask)
*a_result = TRUE ;
else
*a_result = FALSE ;
return TRUE ;
}
Bool
ephyrHostXVAdaptorHasGetStill (const EphyrHostXVAdaptor *a_this,
Bool *a_result)
{
EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
if (((XvAdaptorInfo*)a_this)->type & XvStillMask && XvOutputMask)
*a_result = TRUE ;
else
*a_result = FALSE ;
@ -396,7 +420,7 @@ ephyrHostXVAdaptorHasPutImage (const EphyrHostXVAdaptor *a_this,
{
EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
if (((XvAdaptorInfo*)a_this)->type & XvImageMask)
if (((XvAdaptorInfo*)a_this)->type & XvImageMask && XvInputMask)
*a_result = TRUE ;
else
*a_result = FALSE ;
@ -739,12 +763,13 @@ ephyrHostXVPutImage (int a_port_id,
XvImage *xv_image=NULL ;
GC gc=0 ;
XGCValues gc_values;
Display *dpy = hostx_get_display () ;
EPHYR_RETURN_VAL_IF_FAIL (a_buf, FALSE) ;
EPHYR_LOG ("enter\n") ;
gc = XCreateGC (hostx_get_display (), hostx_get_window (), 0L, &gc_values);
gc = XCreateGC (dpy, hostx_get_window (), 0L, &gc_values);
if (!gc) {
EPHYR_LOG_ERROR ("failed to create gc \n") ;
goto out ;
@ -757,11 +782,11 @@ ephyrHostXVPutImage (int a_port_id,
goto out ;
}
xv_image->data = (char*)a_buf ;
XvPutImage (hostx_get_display (), a_port_id, hostx_get_window (),
XvPutImage (dpy, a_port_id, hostx_get_window (),
gc, xv_image,
a_src_x, a_src_y, a_src_w, a_src_h,
a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
XFlush (hostx_get_display ()) ;
XFlush (dpy) ;
is_ok = TRUE ;
out:
@ -771,5 +796,158 @@ out:
XFree (xv_image) ;
xv_image = NULL ;
}
if (gc) {
XFreeGC (dpy, gc) ;
gc = NULL ;
}
return is_ok ;
}
Bool
ephyrHostXVPutVideo (int a_port_id,
int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
{
Bool is_ok=FALSE ;
int res=FALSE ;
GC gc=0 ;
XGCValues gc_values;
Display *dpy=hostx_get_display () ;
EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
gc = XCreateGC (dpy, hostx_get_window (), 0L, &gc_values);
if (!gc) {
EPHYR_LOG_ERROR ("failed to create gc \n") ;
goto out ;
}
res = XvPutVideo (dpy, a_port_id, hostx_get_window (), gc,
a_vid_x, a_vid_y, a_vid_w, a_vid_h,
a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
if (res != Success) {
EPHYR_LOG_ERROR ("XvPutVideo() failed: %d\n", res) ;
goto out ;
}
is_ok = TRUE ;
out:
if (gc) {
XFreeGC (dpy, gc) ;
gc = NULL ;
}
return is_ok ;
}
Bool
ephyrHostXVGetVideo (int a_port_id,
int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
{
Bool is_ok=FALSE ;
int res=FALSE ;
GC gc=0 ;
XGCValues gc_values;
Display *dpy=hostx_get_display () ;
EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
gc = XCreateGC (dpy, hostx_get_window (), 0L, &gc_values);
if (!gc) {
EPHYR_LOG_ERROR ("failed to create gc \n") ;
goto out ;
}
res = XvGetVideo (dpy, a_port_id, hostx_get_window (), gc,
a_vid_x, a_vid_y, a_vid_w, a_vid_h,
a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
if (res != Success) {
EPHYR_LOG_ERROR ("XvGetVideo() failed: %d\n", res) ;
goto out ;
}
is_ok = TRUE ;
out:
if (gc) {
XFreeGC (dpy, gc) ;
gc = NULL ;
}
return is_ok ;
}
Bool
ephyrHostXVPutStill (int a_port_id,
int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
{
Bool is_ok=FALSE ;
int res=FALSE ;
GC gc=0 ;
XGCValues gc_values;
Display *dpy=hostx_get_display () ;
EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
gc = XCreateGC (dpy, hostx_get_window (), 0L, &gc_values);
if (!gc) {
EPHYR_LOG_ERROR ("failed to create gc \n") ;
goto out ;
}
res = XvPutStill (dpy, a_port_id, hostx_get_window (), gc,
a_vid_x, a_vid_y, a_vid_w, a_vid_h,
a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
if (res != Success) {
EPHYR_LOG_ERROR ("XvPutStill() failed: %d\n", res) ;
goto out ;
}
is_ok = TRUE ;
out:
if (gc) {
XFreeGC (dpy, gc) ;
gc = NULL ;
}
return is_ok ;
}
Bool
ephyrHostXVGetStill (int a_port_id,
int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
{
Bool is_ok=FALSE ;
int res=FALSE ;
GC gc=0 ;
XGCValues gc_values;
Display *dpy=hostx_get_display () ;
EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
gc = XCreateGC (dpy, hostx_get_window (), 0L, &gc_values);
if (!gc) {
EPHYR_LOG_ERROR ("failed to create gc \n") ;
goto out ;
}
res = XvGetStill (dpy, a_port_id, hostx_get_window (), gc,
a_vid_x, a_vid_y, a_vid_w, a_vid_h,
a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
if (res != Success) {
EPHYR_LOG_ERROR ("XvGetStill() failed: %d\n", res) ;
goto out ;
}
is_ok = TRUE ;
out:
if (gc) {
XFreeGC (dpy, gc) ;
gc = NULL ;
}
return is_ok ;
}

View File

@ -111,8 +111,12 @@ int ephyrHostXVAdaptorGetFirstPortID (const EphyrHostXVAdaptor *a_this) ;
Bool ephyrHostXVAdaptorHasPutVideo (const EphyrHostXVAdaptor *a_this,
Bool *a_result) ;
Bool ephyrHostXVAdaptorHasGetVideo (const EphyrHostXVAdaptor *a_this,
Bool *a_result) ;
Bool ephyrHostXVAdaptorHasPutStill (const EphyrHostXVAdaptor *a_this,
Bool *a_result) ;
Bool ephyrHostXVAdaptorHasGetStill (const EphyrHostXVAdaptor *a_this,
Bool *a_result) ;
Bool ephyrHostXVAdaptorHasPutImage (const EphyrHostXVAdaptor *a_this,
Bool *a_result) ;
@ -195,5 +199,23 @@ Bool ephyrHostXVPutImage (int a_port_id,
int a_image_height,
unsigned char *a_buf) ;
/*
* Putvideo/PutStill/GetVideo
*/
Bool ephyrHostXVPutVideo (int a_port_id,
int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
Bool ephyrHostXVGetVideo (int a_port_id,
int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
Bool ephyrHostXVPutStill (int a_port_id,
int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
Bool ephyrHostXVGetStill (int a_port_id,
int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
#endif /*__EPHYRHOSTVIDEO_H__*/

View File

@ -97,24 +97,6 @@ static void ephyrQueryBestSize (KdScreenInfo *a_info,
unsigned int *a_prefered_h,
pointer a_port_priv);
static int ephyrPutVideo (KdScreenInfo *a_screen,
DrawablePtr a_drw,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clip_region,
pointer a_port_priv) ;
static int ephyrPutStill (KdScreenInfo *a_screen,
DrawablePtr a_drw,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clip_region,
pointer a_port_priv) ;
static int ephyrPutImage (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_src_x,
@ -133,6 +115,42 @@ static int ephyrPutImage (KdScreenInfo *a_info,
RegionPtr a_clipping_region,
pointer a_port_priv);
static int ephyrPutVideo (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clip_region,
pointer a_port_priv) ;
static int ephyrGetVideo (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clip_region,
pointer a_port_priv) ;
static int ephyrPutStill (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clip_region,
pointer a_port_priv) ;
static int ephyrGetStill (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clip_region,
pointer a_port_priv) ;
static int ephyrQueryImageAttributes (KdScreenInfo *a_info,
int a_id,
unsigned short *a_w,
@ -546,12 +564,26 @@ ephyrXVPrivSetAdaptorsHooks (EphyrXVPriv *a_this)
if (has_it)
a_this->adaptors[i].PutVideo = ephyrPutVideo;
has_it = FALSE ;
if (!ephyrHostXVAdaptorHasGetVideo (cur_host_adaptor, &has_it)) {
EPHYR_LOG_ERROR ("error\n") ;
}
if (has_it)
a_this->adaptors[i].GetVideo = ephyrGetVideo;
has_it = FALSE ;
if (!ephyrHostXVAdaptorHasPutStill (cur_host_adaptor, &has_it)) {
EPHYR_LOG_ERROR ("error\n") ;
}
if (has_it)
a_this->adaptors[i].PutStill = ephyrPutStill;
has_it = FALSE ;
if (!ephyrHostXVAdaptorHasGetStill (cur_host_adaptor, &has_it)) {
EPHYR_LOG_ERROR ("error\n") ;
}
if (has_it)
a_this->adaptors[i].GetStill = ephyrGetStill;
}
EPHYR_LOG ("leave\n") ;
return TRUE ;
@ -764,36 +796,6 @@ ephyrQueryBestSize (KdScreenInfo *a_info,
EPHYR_LOG ("leave\n") ;
}
static int
ephyrPutVideo (KdScreenInfo *a_screen,
DrawablePtr a_drw,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clip_region,
pointer a_port_priv)
{
EPHYR_LOG ("enter\n") ;
return Success ;
EPHYR_LOG ("leave\n") ;
}
static int
ephyrPutStill (KdScreenInfo *a_screen,
DrawablePtr a_drw,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clip_region,
pointer a_port_priv)
{
EPHYR_LOG ("enter\n") ;
return Success ;
EPHYR_LOG ("leave\n") ;
}
static int
ephyrPutImage (KdScreenInfo *a_info,
DrawablePtr a_drawable,
@ -855,6 +857,202 @@ out:
return result ;
}
static int
ephyrPutVideo (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clipping_region,
pointer a_port_priv)
{
EphyrPortPriv *port_priv = a_port_priv ;
BoxRec clipped_area, dst_box ;
int result=BadImplementation ;
int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
EPHYR_LOG ("enter\n") ;
dst_box.x1 = a_drw_x ;
dst_box.x2 = a_drw_x + a_drw_w;
dst_box.y1 = a_drw_y ;
dst_box.y2 = a_drw_y + a_drw_h;
if (!DoSimpleClip (&dst_box,
REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
&clipped_area)) {
EPHYR_LOG_ERROR ("failed to simple clip\n") ;
goto out ;
}
drw_x = clipped_area.x1 ;
drw_y = clipped_area.y1 ;
drw_w = clipped_area.x2 - clipped_area.x1 ;
drw_h = clipped_area.y2 - clipped_area.y1 ;
if (!ephyrHostXVPutVideo (port_priv->port_number,
a_vid_x, a_vid_y, a_vid_w, a_vid_h,
a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
EPHYR_LOG_ERROR ("ephyrHostXVPutVideo() failed\n") ;
goto out ;
}
result = Success ;
out:
EPHYR_LOG ("leave\n") ;
return result ;
}
static int
ephyrGetVideo (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clipping_region,
pointer a_port_priv)
{
EphyrPortPriv *port_priv = a_port_priv ;
BoxRec clipped_area, dst_box ;
int result=BadImplementation ;
int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
EPHYR_LOG ("enter\n") ;
dst_box.x1 = a_drw_x ;
dst_box.x2 = a_drw_x + a_drw_w;
dst_box.y1 = a_drw_y ;
dst_box.y2 = a_drw_y + a_drw_h;
if (!DoSimpleClip (&dst_box,
REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
&clipped_area)) {
EPHYR_LOG_ERROR ("failed to simple clip\n") ;
goto out ;
}
drw_x = clipped_area.x1 ;
drw_y = clipped_area.y1 ;
drw_w = clipped_area.x2 - clipped_area.x1 ;
drw_h = clipped_area.y2 - clipped_area.y1 ;
if (!ephyrHostXVGetVideo (port_priv->port_number,
a_vid_x, a_vid_y, a_vid_w, a_vid_h,
a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
EPHYR_LOG_ERROR ("ephyrHostXVGetVideo() failed\n") ;
goto out ;
}
result = Success ;
out:
EPHYR_LOG ("leave\n") ;
return result ;
}
static int
ephyrPutStill (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clipping_region,
pointer a_port_priv)
{
EphyrPortPriv *port_priv = a_port_priv ;
BoxRec clipped_area, dst_box ;
int result=BadImplementation ;
int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
EPHYR_LOG ("enter\n") ;
dst_box.x1 = a_drw_x ;
dst_box.x2 = a_drw_x + a_drw_w;
dst_box.y1 = a_drw_y ;
dst_box.y2 = a_drw_y + a_drw_h;
if (!DoSimpleClip (&dst_box,
REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
&clipped_area)) {
EPHYR_LOG_ERROR ("failed to simple clip\n") ;
goto out ;
}
drw_x = clipped_area.x1 ;
drw_y = clipped_area.y1 ;
drw_w = clipped_area.x2 - clipped_area.x1 ;
drw_h = clipped_area.y2 - clipped_area.y1 ;
if (!ephyrHostXVPutStill (port_priv->port_number,
a_vid_x, a_vid_y, a_vid_w, a_vid_h,
a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
EPHYR_LOG_ERROR ("ephyrHostXVPutStill() failed\n") ;
goto out ;
}
result = Success ;
out:
EPHYR_LOG ("leave\n") ;
return result ;
}
static int
ephyrGetStill (KdScreenInfo *a_info,
DrawablePtr a_drawable,
short a_vid_x, short a_vid_y,
short a_drw_x, short a_drw_y,
short a_vid_w, short a_vid_h,
short a_drw_w, short a_drw_h,
RegionPtr a_clipping_region,
pointer a_port_priv)
{
EphyrPortPriv *port_priv = a_port_priv ;
BoxRec clipped_area, dst_box ;
int result=BadImplementation ;
int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
EPHYR_LOG ("enter\n") ;
dst_box.x1 = a_drw_x ;
dst_box.x2 = a_drw_x + a_drw_w;
dst_box.y1 = a_drw_y ;
dst_box.y2 = a_drw_y + a_drw_h;
if (!DoSimpleClip (&dst_box,
REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
&clipped_area)) {
EPHYR_LOG_ERROR ("failed to simple clip\n") ;
goto out ;
}
drw_x = clipped_area.x1 ;
drw_y = clipped_area.y1 ;
drw_w = clipped_area.x2 - clipped_area.x1 ;
drw_h = clipped_area.y2 - clipped_area.y1 ;
if (!ephyrHostXVGetStill (port_priv->port_number,
a_vid_x, a_vid_y, a_vid_w, a_vid_h,
a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
EPHYR_LOG_ERROR ("ephyrHostXVGetStill() failed\n") ;
goto out ;
}
result = Success ;
out:
EPHYR_LOG ("leave\n") ;
return result ;
}
static int
ephyrQueryImageAttributes (KdScreenInfo *a_info,
int a_id,